๐๐ป๐๐ฒ๐ฟ๐๐ถ๐ฒ๐๐ฒ๐ฟ:
You have 2 minutes to solve this Power BI problem.
You have a Sales table with the following columns:
โข Order Date
โข Sales
Create a DAX measure to calculate Year-over-Year (YoY) Sales Growth %.
๐ ๐ฒ: Challenge accepted! ๐ช
YoY Growth % =
VAR CurrentYearSales = [Total Sales]
VAR PreviousYearSales =
CALCULATE(
[Total Sales],
SAMEPERIODLASTYEAR('Calendar'[Date])
)
RETURN
DIVIDE(
CurrentYearSales - PreviousYearSales,
PreviousYearSales,
0
)
๐ก Explanation:
This measure calculates the percentage growth in sales compared to the same period in the previous year.
โข
CurrentYearSales stores the current period's sales.โข
SAMEPERIODLASTYEAR() retrieves sales for the same period last year.โข
DIVIDE() safely calculates the percentage growth and avoids divide-by-zero errors.This challenge tests your understanding of:
โ Variables (VAR)
โ CALCULATE()
โ SAMEPERIODLASTYEAR()
โ DIVIDE()
โ Time Intelligence
๐ฏ Expected Output Example
For Year 2025: Sales = 120,000, Previous Year Sales = 100,000, YoY Growth % = 20%
For Year 2026: Sales = 150,000, Previous Year Sales = 120,000, YoY Growth % = 25%
๐ Bonus (YoY Sales Difference)
YoY Sales Difference =
[Total Sales] -
CALCULATE(
[Total Sales],
SAMEPERIODLASTYEAR('Calendar'[Date])
)
This measure returns the absolute increase or decrease in sales compared to the previous year.
๐ Tip for Power BI Job Seekers:
CALCULATE() is the most important DAX function. Learn how it modifies the filter context because it's used in almost every advanced Power BI interview question.
Power BI Resources: https://whatsapp.com/channel/0029Vai1xKf1dAvuk6s1v22c
โค๏ธ React with โค๏ธ for more Power BI interview challenges!