Power BI Advanced AnalyticsLesson 45 of 53
Lesson 45 of 53

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).

MonthCurrent Revenue (₹)Prior Year Revenue (₹)YoY Growth %DAX Function Used
Oct 20262,40,0002,00,000+20.0%SAMEPERIODLASTYEAR(Date)
Nov 20262,75,0002,50,000+10.0%SAMEPERIODLASTYEAR(Date)
Prior Month (MoM)2,75,0002,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:

Function 1

SAMEPERIODLASTYEAR Function

Definition: Returns a table containing a set of dates in the current filter context shifted exactly one year back in time.

Syntax:
Sales SPLY = CALCULATE([Total Sales], SAMEPERIODLASTYEAR(Dim_Date[Date]))
Parameters Breakdown:
  • Dates: The date column from a marked Date table.
Real-World Example (Year-over-Year (YoY) Sales Comparison):
Problem / Scenario: How do you compare October 2026 Diwali sales against October 2025 sales?
Formula: Prior Year Sales = CALCULATE([Total Sales], SAMEPERIODLASTYEAR(Dim_Date[Date]))
Result: ₹ 45,00,000 (Last Year)
Why it works: SAMEPERIODLASTYEAR shifts the October date window exactly 365 days back, returning historical sales.
Function 2

DATEADD Function

Definition: Versatile time intelligence function that shifts dates by a specified number of intervals (DAY, MONTH, QUARTER, or YEAR).

Syntax:
Sales Last Month = CALCULATE([Total Sales], DATEADD(Dim_Date[Date], -1, MONTH))
Parameters Breakdown:
  • 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`.
Real-World Example (Month-over-Month (MoM) Growth):
Problem / Scenario: How do you calculate sales for the previous month in a monthly trend visual?
Formula: Prior Month Sales = CALCULATE([Total Sales], DATEADD(Dim_Date[Date], -1, MONTH))
Result: ₹ 12,80,000
Why it works: DATEADD dynamically shifts the visible month filter exactly one month prior, enabling MoM variance %.

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

ActionWindowsMac
Quick Measure: YoY GrowthQuick Measure -> Time Intelligence -> Year-over-year changeQuick Measure
Format PercentageMeasure 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.