← All challenges

D7 · DAX · Time intelligence · about 20 min

Running Total by Season

medium

The league office tracks runs scored so far in each season, month by month. The draft line chart keeps climbing in 2025 as if the 2024 season never ended: April 2025 already shows more runs than all of 2024.

Your task

Create a measure named [Season Runs to Date]: runs scored from the start of the season (the calendar year) up to the end of the current period, using the Date table. It must restart at zero each season, respond to the Team filter, and stay blank before a season's first game.

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
    A table with Year and Month from the Date table, all teams. The total must restart in January 2025.
  • T2One team, 2025 by month
    Harbor Hawks, Year slicer set to 2025, one row per month.
  • T3By year
    One row per year: each year shows that season's total, not a total carried over from the year before.

Stuck?

Open one hint at a time.

Hint 1

A running total removes the filter on the current month and keeps every date up to the end of it. Which dates should it keep when the month is April 2025?

Hint 2

The dates to keep are the ones in the same year as the current period and on or before its last day. Removing every filter on the Date table also removes the year.

Hint 3 (near-answer)

TOTALYTD( SUM( Batting[Runs] ), 'Date'[Date] ), or CALCULATE with DATESYTD( 'Date'[Date] ). Both use the Date table, so they restart each January.

Show the editorial

Solve it first if you can: the editorial gives the answer away.

The trap

The usual running-total pattern, FILTER( ALL( 'Date' ), 'Date'[Date] <= MAX( 'Date'[Date] ) ), removes every filter on the Date table, the year included. So April 2025 adds up every game since the first one in 2024. Writing the same pattern over Games[Date] fails the other way: the Date table's month filter still reaches Games through the relationship, so each month shows only its own runs.

The fix

TOTALYTD( SUM( Batting[Runs] ), 'Date'[Date] ).

Why it works

DATESYTD, which TOTALYTD uses, returns the dates from 1 January of the current period's year up to its last date. That replaces the month filter but keeps the year, so the total restarts every season. It works on the Date table because that table has every day; months after the season (October to December) keep showing the season's total, and months before the first game stay blank.

A running total must say where it starts. "All dates up to now" never restarts; "year to date" restarts each year.