All DAX Functions

SAMEPERIODLASTYEAR(): Year-over-Year (YoY) Comparisons

Shift dates exactly one year back for YoY metrics.

On this page

Overview

SAMEPERIODLASTYEAR shifts the active date filter context back exactly one calendar year while preserving the grain of the current period (day, month, quarter). It is the standard function for year-over-year (YoY) comparisons in time-intelligence measures.

It requires a contiguous Date table marked as a date table and an active relationship between your fact table and that Date table.

Sample Data: Sales

A simplified Sales fact table with a related Date column (OrderDate). Amounts are in USD:

Sample Data Table: Sales

OrderIDOrderDateRegionAmount
2012024-01-15North1200
2022024-02-10South800
2032024-03-05North1500
2042025-01-20North1400
2052025-02-12South950
2062025-03-08West1100

The DAX Measures

Total Revenue
Total Revenue = SUM(Sales[Amount])
Revenue Last Year (SAMEPERIODLASTYEAR)
Revenue Last Year =
CALCULATE(
    [Total Revenue],
    SAMEPERIODLASTYEAR('Date'[Date])
)
YoY % Change (optional)
Revenue YoY % =
DIVIDE(
    [Total Revenue] - [Revenue Last Year],
    [Revenue Last Year]
)

Expected Output: YoY Table

Place Date[Month] (or Month name) on rows with [Total Revenue], [Revenue Last Year], and [Revenue YoY %] in a matrix or table visual. Filter the report to year 2025:

Output Table Visual (2025 filter active)

MonthTotal RevenueRevenue Last YearRevenue YoY %
January1400120016.7%
February95080018.8%
March11001500-26.7%
Total34503500-1.4%

Why Did This Output Happen?

For each visible month in 2025, SAMEPERIODLASTYEAR replaces the current date context with the same calendar month one year earlier. January 2025 compares to January 2024 ($1400 vs $1200). March 2025 looks weaker because March 2024 had a larger North order ($1500). The function does not return a full prior-year total in one cell—it always mirrors the same period as the row or slicer grain.

  • Works best when your Date table has no gaps and is marked as a date table.
  • Respects slicers: if you slice to Q1 2025, last year is Q1 2024 only.
  • Pair with CALCULATE so the time shift applies to any base measure.