DAX TOTALYTD function
Calculates a value from the start of the year to the last date in view.
TOTALYTD gives year-to-date figures in one line. It restarts every January (or at a year end you choose) and needs a proper date table.
Syntax
TOTALYTD(<expression>, <dates>[, <filter>][, <year_end_date>])| Argument | Required | Description |
|---|---|---|
| expression | Required | What to accumulate, usually a measure. |
| dates | Required | The date column of your date table. |
| filter | Optional | An extra filter, as in CALCULATE. |
| year_end_date | Optional | A fiscal year end, like "06-30". Default is December 31. |
Returns: A decimal number.
Examples
Calculated on the free practice data (table financials), with [Total Sales] = SUM(financials[Sales]) and [Total Profit] = SUM(financials[Profit]).
1. Sales year-to-date by month
Sales YTD = TOTALYTD([Total Sales], Dates[Date])| Month Year | Sales YTD |
|---|---|
| Sep 2013 | 4,484,000.03 |
| Oct 2013 | 13,779,611.13 |
| Nov 2013 | 21,046,814.43 |
| Dec 2013 | 26,415,255.51 |
| Jan 2014 | 6,607,761.69 |
| Feb 2014 | 13,905,293.08 |
| Mar 2014 | 19,492,152.95 |
The total keeps growing through 2013, then starts again in January 2014.
Good to know
- The date column must come from a date table with every day and no gaps, marked as date table.
- The long form is CALCULATE([Total Sales], DATESYTD(Dates[Date])).
Related functions
Official reference: TOTALYTD function on Microsoft Learn