Stop 10 · Time IntelligenceTopics · 4/9

SAMEPERIODLASTYEAR

Part of the Power BI Roadmap

In short

A number alone means little. "₹14 lakh in July" becomes a story when you know last July was ₹11 lakh. SAMEPERIODLASTYEAR fetches that comparison for any period you're looking at.

SAMEPERIODLASTYEAR shifts the dates in the current context back one year, so CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) ) gives last year's sales for the same period.

The jaadu holds two framed photos side by side of the same decorated doorway, one slightly faded, comparing them with a big smile.

Think of it like this

Last year's festival photo

Every Ganesh Chaturthi your family takes a photo at the same spot. Holding this year's photo next to last year's, you instantly see who grew taller. SAMEPERIODLASTYEAR is that old photo: same spot, same days, exactly one year earlier.

Watch it happen

Shifting the selected dates back one year

1 Jul 2026
0
…
1
31 Jul 2026
2
1 Jul 2025
3
…
4
31 Jul 2025
5

1/4The visual row is July 2026, so the filter context holds 1 to 31 July 2026.

The big ideas

What you need to know

Shifts the whole range

Whatever dates are in context, a day, a month, a fiscal year, move back exactly one year.

Used inside CALCULATE

It returns a table of dates, so it's a filter argument: CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) ).

Needs last year in the table

Your date table must cover the previous year too, or the comparison returns blank.

Stacks with YTD

Apply it to a YTD measure to get last year's YTD up to the same point.

See it in code

Walk through the code

dax
1Sales PY =2CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )3 4Sales PY FYTD =5CALCULATE ( [Sales FYTD], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )6 7Sales vs PY =8[Total Sales] - [Sales PY]

1/3Same dates, one year back. Works by day, month, quarter or year.

Previous year sales, previous year fiscal YTD, and the rupee difference.

Save yourself the pain

Common mistakes

Oops

Passing Sales[OrderDate] instead of 'Date'[Date].

Do this instead

Always use the date column of your marked date table so every day is available.

Oops

Comparing a partial current month with a full month last year.

Do this instead

If July 2026 has only 12 days of data, compare with the same 12 days, for example by limiting dates to the last sales date.

Your mission

This year vs last year

~15 min

Quick check

What type of value does SAMEPERIODLASTYEAR return?

Go deeper

  1. 1Create a Sales PY measure.
  2. 2Show it next to Total Sales by month in a table.
  3. 3Check that it still works at quarter and year level.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge