16.2Comparing with another period

You will often compare this month with the same month last year, or with the month before. Two functions shift the dates of the context, SAMEPERIODLASTYEAR by one year back, DATEADD by as many periods as you want.

16.2.1SAMEPERIODLASTYEAR

In Excel
ExcelSUMIFS with EDATE(…,-12)
Match

You need it to place, next to a number, the number of the same days one year earlier, like the revenue of March 2024 next to that of March 2025.

SAMEPERIODLASTYEAR returns the same days, one year earlier.

SAMEPERIODLASTYEAR( <dates> )

It expects a single argument, the date column of the date table, here Calendar[Date]. It returns a table of dates, which CALCULATE uses as a filter. Let us put this measure in a table by year:

Revenue Previous Year = CALCULATE( [Revenue], SAMEPERIODLASTYEAR( Calendar[Date] ) )
Power BI accepts this DAX foryes, Measureyes, Calculated columnno, Calculated tableno, Virtual table
In plain words

“I want the revenue of the same days, one year earlier.”

Table visual, The “Revenue Previous Year” measure by year
YearRevenue Previous Year
2025750,000
Total750,000

This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.

On the 2025 row, Calendar[Date] contains the days of 2025. SAMEPERIODLASTYEAR receives these days and returns the same ones, one year earlier, those of 2024. CALCULATE replaces the filter on the dates with them, then [Revenue] adds up the sales of those days, 750,000. The 2024 row disappears, because 2023 has no sales.

The change is then calculated with DIVIDE, in the same table by year:

Change = DIVIDE( [Revenue] - [Revenue Previous Year], [Revenue Previous Year] )
Power BI accepts this DAX foryes, Measureyes, Calculated columnno, Calculated tableno, Virtual table
In plain words

“I want the revenue minus that of the previous year, divided by that of the previous year.”

In 2025, sales go from 750,000 to 950,000, an increase of 26.7%.

Tip

In 2024, the previous year has no sales. DIVIDE receives a blank denominator, and returns a blank, where the / operator would give infinity. The 2024 row therefore stays blank.

Practice

Each exercise is solved with the function you just discovered. Two exercises per function, a direct use and a combined use, from easiest to hardest, on data other than the course data. Pick the right formula out of five.

  1. Direct useMeasureDifficulty

    A museum already has a “Visitors” measure, the sum of the “Visitors” column of the “Admissions” table. The “Days” date table, with its “Date” column, is marked as a date table and linked to “Admissions.” In a visual by month, write the “Visitors Last Year” measure, which returns the visitors of the same days, one year earlier.

    Admissions
    DateVisitors
    7/14/20251200
    8/15/2025900
    7/14/20261500

    Which formula should you write for “Visitors Last Year”?

  2. Combined useMeasureDifficulty

    A hotel records each booking on a row of the “Bookings” table. The “Bookings” measure counts these rows. The “Days” date table, with its “Date” column, is marked and linked to “Bookings.” In a visual by month, write the “Change from Last Year” measure, by how much the bookings of the month changed compared with the same month, one year earlier.

    Bookings
    RoomDate
    1018/3/2025
    1028/10/2025
    1038/24/2025
    1018/5/2026

The rest of this lesson is part of izyDAX Pro

You have just read the first section. The next one, its animations, the exercises and the summary are waiting for you with izyDAX Pro, in a single payment.