Year over year in DAX: SAMEPERIODLASTYEAR and DATEADD

How to compare with last year in DAX, SAMEPERIODLASTYEAR, DATEADD and PARALLELPERIOD compared, growth percentages, month over month and quarter over quarter, comparing partial periods fairly, and showing the change in visuals.

Short answer: last year's value is CALCULATE ( [Revenue], SAMEPERIODLASTYEAR ( 'Date'[Date] ) ). DATEADD ( 'Date'[Date], -1, YEAR ) does the same and also shifts by months, quarters or days (-1, MONTH for the previous month). PARALLELPERIOD ( 'Date'[Date], -1, YEAR ) returns the whole previous year, whatever part of the year is filtered. Growth is DIVIDE ( [Revenue] - [Revenue LY], [Revenue LY] ).

A number without a comparison means little. "1.2 million in October" becomes useful as "1.2 million, 8% more than last October", and that needs one measure.

What do the three functions return?

FunctionReturns
SAMEPERIODLASTYEAR ( 'Date'[Date] )1 to 31 March 2025
DATEADD ( 'Date'[Date], -1, YEAR )1 to 31 March 2025
DATEADD ( 'Date'[Date], -1, MONTH )1 to 28 February 2026
DATEADD ( 'Date'[Date], -1, QUARTER )1 to 31 December 2025
PARALLELPERIOD ( 'Date'[Date], -1, YEAR )1 January to 31 December 2025
PARALLELPERIOD ( 'Date'[Date], -1, MONTH )1 to 28 February 2026
With March 2026 in the filter context

SAMEPERIODLASTYEAR ( dates ) is the same as DATEADD ( dates, -1, YEAR ). DATEADD shifts the exact dates in context; PARALLELPERIOD returns complete periods at the given level.

Which measures do you need?

Revenue LY = CALCULATE ( [Revenue], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )

Revenue vs LY = [Revenue] - [Revenue LY]

Revenue vs LY % =
VAR LY = [Revenue LY]
RETURN IF ( NOT ISBLANK ( LY ), DIVIDE ( [Revenue] - LY, LY ) )

Revenue PM = CALCULATE ( [Revenue], DATEADD ( 'Date'[Date], -1, MONTH ) )
Revenue vs PM % = DIVIDE ( [Revenue] - [Revenue PM], [Revenue PM] )

Revenue PQ = CALCULATE ( [Revenue], DATEADD ( 'Date'[Date], -1, QUARTER ) )

Revenue Full LY = CALCULATE ( [Revenue], PARALLELPERIOD ( 'Date'[Date], -1, YEAR ) )

-- share of last year's full total reached so far
Pace vs Full LY = DIVIDE ( [Revenue YTD], [Revenue Full LY] )
  • Revenue
  • vs LY %
05010015020002.557.51012.5JanFebMarAprMayJun
Revenue by month with growth against last year

How do you compare partial periods fairly?

In October, "this year" has 29 days of October and last year's October has 31. Two fixes:

-- 1 last year, only up to the same day
Revenue LY to Date =
VAR LastSale = CALCULATE ( MAX ( Sales[Order Date] ), REMOVEFILTERS ( 'Date' ) )
RETURN
    CALCULATE (
        [Revenue],
        SAMEPERIODLASTYEAR ( 'Date'[Date] ),
        'Date'[Date] <= EDATE ( LastSale, -12 )
    )

-- 2 per working day
Revenue per Working Day = DIVIDE ( [Revenue], [Working Days] )

Option 1 compares 1 to 29 October with 1 to 29 October last year. Option 2 removes the effect of different numbers of working days, useful when a month has more weekends than last year.

How should the change be shown?

  • In a table, a vs LY % column with conditional formatting (good, bad).
  • In a column chart, last year as a second series or as a line (combo).
  • On a card, the reference label "vs last year" under the value (see card visual).
  • In a KPI visual, last year as the target.

What goes wrong?

  • New products or stores. Growth is infinite or blank when last year is blank; show it as "new" with the ISBLANK test above.
  • Shifting a fact table date column. Always shift the date table's column.
  • Comparing a running month with a full one. Limit last year to the same day.
  • PARALLELPERIOD where DATEADD was meant. The month filter becomes a full year: totals look far too big.
  • 53-week years and calendars. Week-based comparisons need calendar-based time intelligence.

Where can you check this?

Where do you start?

Write Revenue LY and Revenue vs LY % once and reuse them on every page; if you have many measures to compare, a calculation group does it for all of them. Rolling 12 months smooths the comparison.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.