D8 · DAX · Time intelligence · about 25 min
Runs vs Last Season
hardCoaches want this season's runs beside the same period last season. The draft column is blank on every month, and a later fix shows the whole of May 2024 even when the date slicer covers only the first half of May 2025.
Your task
Create a measure named [Runs Last Season]: the runs scored in the same period one year earlier, using the Date table. It must work at year, month and day level, respond to the Team filter, and match the exact dates selected (1–15 May 2025 compares with 1–15 May 2024).
What the grader checks
You see the situations, not the expected numbers. The expected values are computed live from your file and the source data.
- T1By month, both seasons
Year and Month from the Date table, all teams. 2024 has no earlier season, so it stays blank; 2025 months show the 2024 numbers. - T2By year
One row per year. - T3One team, 2025 by month
Riverton Rams, Year slicer set to 2025, one row per month. - T4Half a month, by team
A date slicer set to 1–15 May 2025, one row per team. Last season means 1–15 May 2024, not all of May.
Stuck?
Open one hint at a time.
Hint 1
Shifting a period by a year needs a list of dates to shift. Which column has every day of both years, and which only has the days a game was played?
Hint 2
Shift the Date table's dates, not the game dates. Also check that the shift keeps the exact days selected, not whole months or a whole year.
Hint 3 (near-answer)
CALCULATE( SUM( Batting[Runs] ), SAMEPERIODLASTYEAR( 'Date'[Date] ) ). DATEADD( 'Date'[Date], -1, YEAR ) works too.
Show the editorial
Solve it first if you can: the editorial gives the answer away.
The trap
SAMEPERIODLASTYEAR( Games[Date] ) shifts the game dates, but the visual's filter on the Date table (Year = 2025, Month = May) stays in place. A 2024 date never meets a 2025 filter, so every row is blank. Filtering Games[Season] to last season fails the same way. Filtering 'Date'[Year] to last year fixes the months but drops a date slicer: half of May 2025 then compares with a blank. PARALLELPERIOD always returns whole months, so 1–15 May compares with all of May.
The fix
CALCULATE( SUM( Batting[Runs] ), SAMEPERIODLASTYEAR( 'Date'[Date] ) ).
Why it works
SAMEPERIODLASTYEAR takes the dates currently selected on the Date table and moves each one back a year. Because the filter is on the Date table's date column, and the table is marked as a date table, the original filters on the Date table (Year, Month, the slicer) are replaced instead of combined, and the shifted days are exactly the selected days one year earlier. Games[Date] can't do this: it only has match days, and filtering it leaves the Date table's own filter in place.
Time intelligence goes on the marked date table's date column, never on the fact table's date.