M7 · Modeling · about 30 min
Targets at the Wrong Grain
hardEach team has a run target per month per season, in a Targets table that isn't related to anything. The first draft matched targets on month number, so April 2025 shows the April 2024 and April 2025 targets added together. A later fix matched year and month separately, which looks right month by month but breaks on a date range that crosses into the next season.
Your task
Create a measure named [Target Runs]: the sum of Targets[TargetRuns] for the teams, seasons and months in the current filter, where the season is 'Date'[Year] and the month is 'Date'[MonthNo]. It must respond to the Team filter and to any Date filter, including a date range across two seasons.
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.
- T1Season x month x team
Year and Month from the Date table, one row per team, all seasons. - T2By team, 2025
Year slicer set to 2025, one row per team. - T3Harbor Hawks by month
Harbor Hawks, one row per year and month. - T4Date range across two seasons
A date slicer from 1 September 2024 to 30 April 2025, one row per team: September 2024 and April 2025 targets only.
Stuck?
Open one hint at a time.
Hint 1
A target belongs to one team, one season and one month. Which of those three does your measure pass to Targets, and does it pass them as a combination?
Hint 2
VALUES of Year and VALUES of MonthNo are two separate lists; Targets receives every combination of them. A range from September 2024 to April 2025 holds only some of those combinations.
Hint 3 (near-answer)
TREATAS( SUMMARIZE( 'Date', 'Date'[Year], 'Date'[MonthNo] ), Targets[Season], Targets[Month] ) passes the actual (year, month) pairs. Add TREATAS( VALUES( Teams[TeamID] ), Targets[TeamID] ), or relate Targets to Teams.
Show the editorial
Solve it first if you can: the editorial gives the answer away.
The trap
Targets are stored per team, season and month, but the Date table filters by day. Matching on month number alone treats April 2024 and April 2025 as the same month, so each April shows both seasons' targets. Matching year and month as two separate filters works when the filter is one month or one year, but Targets then receives every combination of the years and the months: a range from September 2024 to April 2025 also brings in April 2024 and September 2025.
The fix
CALCULATE( SUM( Targets[TargetRuns] ), TREATAS( SUMMARIZE( 'Date', 'Date'[Year], 'Date'[MonthNo] ), Targets[Season], Targets[Month] ), TREATAS( VALUES( Teams[TeamID] ), Targets[TeamID] ) ).
Why it works
SUMMARIZE returns the (year, month) pairs that actually exist in the current Date filter, and TREATAS applies them to Targets as pairs, so only those season-month rows survive. The team filter is passed the same way, or through a relationship from Targets[TeamID] to Teams, since team is a single column. Each filter now reaches Targets at the grain Targets is stored at.
Filter a table at its own grain: when the key has two parts, pass them together, as pairs.