D6 · DAX · Iterators · about 15 min
Best Scoring Game
mediumThe season review wants each team's best offensive game. The draft says Riverton Rams' best game was 4 runs. They scored 10 in one game in April 2025.
Your task
Create a measure named [Best Game Runs]: the most runs the team scored in a single game, in the current filter. It must respond to the Team, Season and Month filters, and stay blank where there are no games.
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 team
One row per team that has played games. - T2By team, Season 2024
Season slicer set to 2024, one row per team that has played games. - T3One team by month
Harbor Hawks in 2025, one row per month. - T4No games, no best game
All six teams, including the expansion team with no games: it must stay blank.
Stuck?
Open one hint at a time.
Hint 1
MAX looks at one column, row by row. What is one row of Batting, and is the number you want on any single row?
Hint 2
First get each game's total runs, then take the biggest. That is an iterator over games, computing a sum for each one.
Hint 3 (near-answer)
MAXX over the games (VALUES( Batting[GameID] ) or Games) of CALCULATE( SUM( Batting[Runs] ) ). The CALCULATE makes each game's sum use that game only.
Show the editorial
Solve it first if you can: the editorial gives the answer away.
The trap
MAX( Batting[Runs] ) returns the highest value on any one batting row: the best a single batter did in a game, usually 3 or 4. The team's game total is not stored on any row. MAXX with a plain SUM inside looks right but returns the team's total runs for the whole filter, because without CALCULATE the SUM ignores which game the iterator is on.
The fix
MAXX( VALUES( Batting[GameID] ), CALCULATE( SUM( Batting[Runs] ) ) ).
Why it works
The number you want only exists after grouping: runs per game. An iterator builds that grouping on the fly. VALUES gives the games in the current filter, CALCULATE turns each game into a filter so the SUM is that game's runs, and MAXX keeps the largest. With no games there is nothing to iterate and the result is blank.
When the number isn't on any row, build it per item with an iterator and CALCULATE, then aggregate those.