🚀 Power BI Interview Challenge #3 🔥
𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄𝗲𝗿: 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!