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
| Excel | SUMIFS 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.
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:
“I want the revenue of the same days, one year earlier.”
| Year | Revenue Previous Year |
|---|---|
| 2025 | 750,000 |
| Total | 750,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:
“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%.
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.
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 Date Visitors 7/14/2025 1200 8/15/2025 900 7/14/2026 1500 Which formula should you write for “Visitors Last Year”?
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 Room Date 101 8/3/2025 102 8/10/2025 103 8/24/2025 101 8/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.