Advanced Visuals: Matrix, Decomposition Tree & Small Multiples
Overview & Learning Objectives
Knowing that you made ₹ 10 Lakhs this month is meaningless without context. Did you grow or decline compared to last month? Compared to the same month last year? In DAX, prior period comparisons are performed using `SAMEPERIODLASTYEAR()` (shifts the current date window back exactly 1 year) and `DATEADD()` (shifts by any number of days, months, quarters, or years).
- Master `SAMEPERIODLASTYEAR(Dim_Date[Date])` for Year-over-Year (YoY) metrics.
- Master `DATEADD(Dim_Date[Date], NumberOfIntervals, Interval)` for flexible time shifts.
- Build dynamic Year-over-Year Growth % measures.
Industry Standard
Standard: Enterprise reporting standards at Flipkart and McKinsey mandate using `DATEADD` for multi-interval shifts (-1 Month, -1 Quarter, -1 Year) and pairing with `DIVIDE()` for YoY growth rates.
Real-World Example: FreshBake Artisan Patisserie
FreshBake compares monthly sales against the same month last year (YoY) and the previous month (MoM).
| Month | Current Revenue (₹) | Prior Year Revenue (₹) | YoY Growth % | DAX Function Used |
|---|---|---|---|---|
| Oct 2026 | 2,40,000 | 2,00,000 | +20.0% | SAMEPERIODLASTYEAR(Date) |
| Nov 2026 | 2,75,000 | 2,50,000 | +10.0% | SAMEPERIODLASTYEAR(Date) |
| Prior Month (MoM) | 2,75,000 | 2,40,000 (Oct 2026) | +14.6% | DATEADD(Date, -1, MONTH) |
Functions Covered in this Chapter
Here is the definition, exact syntax, parameter breakdown, and real-world business example for each function covered in this chapter:
SAMEPERIODLASTYEAR Function
Definition: Returns a table containing a set of dates in the current filter context shifted exactly one year back in time.
Sales SPLY = CALCULATE([Total Sales], SAMEPERIODLASTYEAR(Dim_Date[Date]))
Dates: The date column from a marked Date table.
Prior Year Sales = CALCULATE([Total Sales], SAMEPERIODLASTYEAR(Dim_Date[Date]))DATEADD Function
Definition: Versatile time intelligence function that shifts dates by a specified number of intervals (DAY, MONTH, QUARTER, or YEAR).
Sales Last Month = CALCULATE([Total Sales], DATEADD(Dim_Date[Date], -1, MONTH))
Dates: Contiguous date column from a marked Date table.NumberOfIntervals: Integer representing how many intervals to shift (negative to shift back, positive for ahead).Interval: The unit: `DAY`, `MONTH`, `QUARTER`, or `YEAR`.
Prior Month Sales = CALCULATE([Total Sales], DATEADD(Dim_Date[Date], -1, MONTH))Common Mistakes & Limitations
- Referencing the Fact table date column inside `SAMEPERIODLASTYEAR`, causing blank or distorted numbers.
- Attempting to calculate YoY growth with `[Sales] - [Sales SPLY] / [Sales SPLY]` without parentheses, violating order of operations.
Keyboard Shortcuts
| Action | Windows | Mac |
|---|---|---|
| Quick Measure: YoY Growth | Quick Measure -> Time Intelligence -> Year-over-year change | Quick Measure |
| Format Percentage | Measure Tools -> % | Measure Tools |
Pro Tips & Modern Alternatives
- Use `DATEADD(Dim_Date[Date], -1, MONTH)` to build Month-over-Month (MoM) comparative growth cards.
- Use `DATEADD(Dim_Date[Date], -7, DAY)` to analyze Week-over-Week (WoW) trends.