SAMEPERIODLASTYEAR and Year-over-Year % in DAX
SAMEPERIODLASTYEAR shifts the current date filter back one year; combine it with DIVIDE to build clear year-over-year percent measures — and name LY vs YTD-LY so nobody confuses the story.
Chala mitrano! “Are we better than last year?” is the board question. Why? Growth needs a parallel period, not vibes. How? We write Sales LY with SAMEPERIODLASTYEAR, then YoY % with DIVIDE, on FreshBasket (fictional) months. Stay precise with names.
Quick answer
Vertical YoY path:
Sales LY = CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) ).- Matrix: Month + Total Sales + Sales LY.
YoY % = DIVIDE ( [Total Sales] - [Sales LY], [Sales LY] ).- Format YoY % as percentage.
- Handle missing LY with DIVIDE (blank/alternate).
- If you shift a YTD measure, call it Sales YTD LY — not plain LY.
CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
DIVIDE ( [Total Sales] - [Sales LY], [Sales LY] )
Why YoY, rows in / number out
| Month | This year | Last year |
|---|---|---|
| Jan | 100 | 90 |
| Feb | 40 | 50 |
| Mar | 80 | 70 |
- Why SAMEPERIODLASTYEAR: board wants March this year vs March last year.
- On March this year,
[Total Sales]= 80. SAMEPERIODLASTYEARshifts the date filter back one year. Sales LY = 70.- YoY % =
DIVIDE ( 80 - 70, 70 )≈ 14.3%. - Feb story: this year 40, LY 50, YoY % is negative — that is honest.
- Mumbai focus: if a City slicer is on, both TY and LY respect Mumbai. City total this year might still be 140 for Jan+Feb while LY is whatever last year held.
SAMEPERIODLASTYEAR shifts the current date filter back one year for a like-for-like compare.
मित्रांनो — SAMEPERIODLASTYEAR shifts the current date filter back one year for a like-for-like compare.
मित्रों — SAMEPERIODLASTYEAR shifts the current date filter back one year for a like-for-like compare.
What do I need before this guide?
- YTD and DIVIDE.
- Course: Time intelligence.
Before and after (look at the tables first)
Before
आधी (Before)
पहले (Before)
After
नंतर (After)
बाद में (After)
SAMEPERIODLASTYEAR
Sales LY =
CALCULATE (
[Total Sales],
SAMEPERIODLASTYEAR ( 'Date'[Date] )
)
- Takes the dates in context and shifts them back one year.
- March 2026 compares with March 2025 when Month is on the axis.
- Needs the same solid Date table as YTD.
YoY percent
YoY % pattern: DIVIDE ( [Sales] - [Sales LY], [Sales LY] ) — then format as percent.
मित्रांनो — YoY % pattern: DIVIDE ( [Sales] - [Sales LY], [Sales LY] ) — then format as percent.
मित्रों — YoY % pattern: DIVIDE ( [Sales] - [Sales LY], [Sales LY] ) — then format as percent.
YoY % =
DIVIDE (
[Total Sales] - [Sales LY],
[Sales LY]
)
- (This year − last year) / last year.
- Format as %.
- Alternative form
DIVIDE ( [Total Sales], [Sales LY] ) - 1— pick one style and stay consistent.
Phone-bill analogy: this month’s bill vs the same month last year. That is SAMEPERIODLASTYEAR. The percent change is DIVIDE.
LY vs YTD LY (naming)
Name measures clearly: parallel period last year is not the same story as “YTD shifted to last year”.
मित्रांनो — Name measures clearly: parallel period last year is not the same story as “YTD shifted to last year”.
मित्रों — Name measures clearly: parallel period last year is not the same story as “YTD shifted to last year”.
- Parallel period last year ≠ “take YTD then shift”.
- Both are valid; titles must say which.
- Interview tip: define the grain before writing DAX.
Mistakes and calm fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| LY blank | No prior-year data / bad dates | Check Date table + data coverage |
| Huge YoY | Wrong denominator | Use Sales LY, not a random total |
| Confusing card | Vague name “Growth” | Call it YoY % |
| YTD mixed in | Copied wrong measure | Separate Sales LY vs Sales YTD LY |
Ghabru naka 😅 — blank LY in year one of a business is normal.
Ravindra Bagale's Tip
Interview trap: “How do you calculate YoY?” Answer with both pieces: SAMEPERIODLASTYEAR for last year, DIVIDE for the percent — then mention the Date table. Got it?
Ravindra Bagale's Tip – मराठी
Interview trap: “YoY कसे calculate करता?” दोन्ही तुकडे सांगा: last year साठी SAMEPERIODLASTYEAR, percent साठी DIVIDE — मग Date table उल्लेख करा. समजलं का?
Ravindra Bagale's Tip – हिंदी
Interview trap: “YoY कैसे calculate करते हो?” दोनों हिस्से बताओ: last year के लिए SAMEPERIODLASTYEAR, percent के लिए DIVIDE — फिर Date table का ज़िक्र करो. समझ में आया?
Practice task
- Create Sales LY and YoY %.
- Month matrix with TY, LY, YoY %.
- Find a month with no LY; note DIVIDE behaviour.
- Optionally build Sales YTD LY with a clear name.
- Write one sentence defining YoY for your report consumers.
Got it? SAMEPERIODLASTYEAR for LY; DIVIDE for YoY %. Name YTD-LY separately. Next: running totals. Let's continue.
समजलं का? SAMEPERIODLASTYEAR for LY; DIVIDE for YoY %. Name YTD-LY separately. Next: running totals. Aata pudhe jaauya.
समझ में आया? SAMEPERIODLASTYEAR for LY; DIVIDE for YoY %. Name YTD-LY separately. Next: running totals. आगे बढ़ते हैं.
Frequently asked questions
What does SAMEPERIODLASTYEAR do?
Returns a set of dates shifted one year back from the dates in the current filter context.
How do I get YoY %?
Compare this period to LY with DIVIDE ( (TY - LY), LY ) or DIVIDE ( TY, LY ) - 1 — be consistent.
LY vs previous month?
Different helpers exist for other shifts; this guide focuses on year-over-year.
Why is LY blank?
No data last year for those dates, broken Date relationship, or filter context with no parallel dates.
Can I combine with YTD?
Yes — patterns like CALCULATE ( [Sales YTD], SAMEPERIODLASTYEAR ( … ) ) exist; name them Sales YTD LY.
Course lesson?
Time intelligence in the DAX chapter.