Power BI and SQL: Asked in Deloite
Power BI and SQL: Asked in Deloite
Data Modeling
Query Reduction
Simplifying data
Minimizing
structures for
queries to
efficiency
enhance speed
---
SELECT ESalary
FROM (SELECT ESalary, ROW_NUMBER() OVER (ORDER BY ESalary DESC) AS rank
FROM Employee) AS ranked_salaries
WHERE rank = 3;
Explanation:
We use ROW_NUMBER() to rank salaries in descending order, then select the row where the
rank is 3.
Usage:
Execute with:
Explanation:
We check if ESalary is odd using ESalary % 2 = 1 and join it with empdetails on EID.
SELECT EID,
ESalary,
LAG(ESalary) OVER (PARTITION BY EID ORDER BY Week) AS PreviousWeekSalary,
ESalary - LAG(ESalary) OVER (PARTITION BY EID ORDER BY Week) AS
WeekChange
FROM EmployeeSalaries;
Explanation:
LAG retrieves the salary from the previous week for comparison. This helps analyze
week-over-week changes.
YoY Growth =
DIVIDE(
[Total Sales] - CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date])),
CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))
)
Explanation:
This measure compares current sales with sales from the same period last year using
SAMEPERIODLASTYEAR.
3. Create slicers for Year, Quarter, and Month to enable dynamic filtering.
---
Data Type
Structure
Detailed data
Highly normalized
Real-time data
Reduces redundancy
Near real-time data
Many tables
Sales transactions
Complex joins
Customer records
Database
Use Case
Users
Applications
Operational users
ERP systems
Clerks
CRM systems
Application users
Purpose
Data Mart:
• Purpose: Stores summarized, subject-specific data for analytical and reporting
purposes.
• Structure: Denormalized structure (fewer tables, star schema) optimized for fast
querying.
• Data Type: Aggregated data focused on a specific business area like Sales, Marketing,
or Finance.
• Use Case: Used to generate reports and dashboards for decision-making.
• Users: Business analysts and decision-makers.
Components of a Data Mart
Users Purpose
The primary users of the The reason for creating
data mart for decision- a data mart to store and
making analyze data
Data Type
The specific aggregated
data stored in the data
mart
————————————————————————————————————————————————
Follow me on Linkedin : https://www.linkedin.com/in/rajatjain01/