DAX SAMEPERIODLASTYEAR Function

Calculate values in the same period in the previous year.

In DAX (Data Analysis Expressions), SAMEPERIODLASTYEAR is a time intelligence function used to return a table that contains a column of dates shifted one year back in time from the dates in a given column.

It's commonly used in measures to compare values from the current period with the same period in the previous year.

Syntax

SAMEPERIODLASTYEAR(<dates>)
  • <dates>: A column containing dates, typically from a properly marked Date table.

Example Usage

Let’s say you have a measure called Total Sales, and you want to calculate the total sales for the same period last year.

Standard Measure

Sales LY :=
CALCULATE(
    [Total Sales],
    SAMEPERIODLASTYEAR('Date'[Date])
)
  • Total Sales is your existing measure, e.g., SUM(Sales[Amount]).
  • 'Date'[Date] is the date column from your date table.

Key Notes

  • The date column must come from a properly marked Date Table (Calendar Table).
  • SAMEPERIODLASTYEAR respects the current context (e.g., it works for months, quarters, days, depending on what is in your visual).
  • Unlike DATEADD, it works best for full periods (e.g., full months or years), not partial periods.

Example Scenario

If you're viewing sales by month in a chart:

  • For March 2025, SAMEPERIODLASTYEAR will return the dates for March 2024.
  • This allows you to show a line chart with current year vs. previous year.
No questions available.