TOTALYTD (Year-to-Date)
Power BI · Advanced DAX & Time Intelligence
Theory
Year-to-date sums a measure from the start of the year up to the last date in the current filter context. TOTALYTD(expression, dates) does this in one function; it is equivalent to CALCULATE(expression, DATESYTD(dates)). The dates argument should be the date column of a marked date table, such as 'Date'[Date], with a relationship to the fact table.
In a visual by month for 2024, the January row shows January's sales (₹1,200), February shows January plus February (₹3,500), March ₹5,700 and April ₹6,200, so the line keeps growing through the year and restarts each January. For a financial year that ends on 31 March, common in India, pass the year-end date as the last argument: TOTALYTD([Total Sales], 'Date'[Date], "3-31"). Related functions are TOTALMTD and TOTALQTD for month- and quarter-to-date.
Why we use it
Leaders track progress against annual targets, so YTD is one of the most requested measures. TOTALYTD gives a correct running total that respects the calendar and slicers.
When to use it
Use it for any cumulative-to-date figure within a year. Use DATESYTD inside CALCULATE when you need to combine it with other filters. For a running total that never resets, use a different pattern with FILTER over ALL dates.
How it works
- Visual cell for a month
- Find the last date in the current context
- Build the set of dates from 1 Jan (or FY start) to that date
- Evaluate the measure over those dates
- Next month in the same year? Yes: Total keeps growing. No: Total restarts in the new year.
- YTD shown per month
Syntax
TOTALYTD(<expression>, <dates>[, <filter>][, <year_end_date>])
CALCULATE(<expression>, DATESYTD(<dates>[, <year_end_date>]))
TOTALQTD / TOTALMTD(<expression>, <dates>[, <filter>])Example
Sales YTD = TOTALYTD([Total Sales], 'Date'[Date])
// Same result with CALCULATE
Sales YTD (calc) = CALCULATE([Total Sales], DATESYTD('Date'[Date]))
// Indian financial year (April to March)
Sales FYTD = TOTALYTD([Total Sales], 'Date'[Date], "3-31")Key points
- TOTALYTD = CALCULATE + DATESYTD
- Needs a proper, marked date table
- Resets at the start of each (financial) year
- Pass a year-end date like "3-31" for April-March years
- TOTALQTD and TOTALMTD work the same way