YTD, QTD and MTD in DAX: running totals in the period

How to calculate year-to-date, quarter-to-date and month-to-date totals in DAX with TOTALYTD, DATESYTD, TOTALQTD, TOTALMTD and their week versions, fiscal years with a year-end date, last year's YTD, stopping at the last date with data, and common mistakes.

Short answer: year to date is TOTALYTD ( [Revenue], 'Date'[Date] ) or, the same, CALCULATE ( [Revenue], DATESYTD ( 'Date'[Date] ) ). Quarter and month to date use TOTALQTD / DATESQTD and TOTALMTD / DATESMTD. For a fiscal year, pass the year-end date: DATESYTD ( 'Date'[Date], "6-30" ) for a year ending 30 June. They need a proper date table. With calendar-based time intelligence, week to date (TOTALWTD) is also available.

"Where are we this year?" is the first question of most sales meetings. A YTD line next to last year's YTD answers it; a monthly column chart does not.

What does YTD look like?

  • 2026 YTD
  • 2025 YTD
02004006008001,000JanFebMarAprMayJun
Revenue year to date, this year against last year (thousands)
Revenue YTD = TOTALYTD ( [Revenue], 'Date'[Date] )

Revenue YTD LY =
CALCULATE ( [Revenue YTD], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )

Revenue YTD vs LY % = DIVIDE ( [Revenue YTD] - [Revenue YTD LY], [Revenue YTD LY] )

Which functions are there?

PeriodTotal functionDates function (for CALCULATE)
YearTOTALYTD ( expr, dates [, filter] [, year_end] )DATESYTD ( dates [, year_end] )
QuarterTOTALQTD ( expr, dates [, filter] )DATESQTD ( dates )
MonthTOTALMTD ( expr, dates [, filter] )DATESMTD ( dates )
WeekTOTALWTD ( expr, calendar )DATESWTD ( calendar )
Period-to-date functions

The week functions work with calendar-based time intelligence, which defines what a week is. The DATES... form is more flexible: it is a filter you can combine with others in one CALCULATE.

Revenue QTD = CALCULATE ( [Revenue], DATESQTD ( 'Date'[Date] ) )
Revenue MTD = CALCULATE ( [Revenue], DATESMTD ( 'Date'[Date] ) )
Online Revenue YTD = CALCULATE ( [Revenue], DATESYTD ( 'Date'[Date] ), Sales[Channel] = "Online" )

How do you handle a fiscal year?

Pass the last day of the fiscal year as month and day:

Revenue FYTD = CALCULATE ( [Revenue], DATESYTD ( 'Date'[Date], "6-30" ) )

The year-end is a text literal (the year part is ignored), read in the locale the file was created in; "6-30" is safe in most. TOTALYTD takes the same year end as its last argument, after an optional filter. Add a Fiscal Year column to the date table so readers slice by fiscal year.

How do you stop the line at today?

The date table runs to 31 December, so a YTD line continues flat to the year end. Return BLANK after the last date with data:

Revenue YTD =
VAR LastSale = CALCULATE ( MAX ( Sales[Order Date] ), REMOVEFILTERS ( 'Date' ) )
RETURN
    IF ( MIN ( 'Date'[Date] ) <= LastSale, TOTALYTD ( [Revenue], 'Date'[Date] ) )

The same applies to last year's YTD when compared to a partial current year: comparing January to June 2026 with all of 2025 is wrong. SAMEPERIODLASTYEAR over the current filter keeps the same dates, as long as the current period stops at the last date with data.

What goes wrong?

  • No date table, or a column from the fact table. DATESYTD ( Sales[Order Date] ) only sees dates with sales; use the date table's column.
  • Gaps in the dates. Classic time intelligence needs contiguous dates; build the table with CALENDAR.
  • YTD flat into the future. Stop at the last data date as above.
  • Comparing a partial year with a full one. Compare YTD with last year's YTD to the same day.
  • Filters that remove the year. YTD works within the year in context; with no year filtered, it calculates to the last date in the context.

Where can you check this?

Where do you start?

Add Revenue YTD and Revenue YTD LY to a line chart by month with the stop at the last sale. Year over year covers the comparison functions in depth.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.