Short answer: DAX time intelligence functions return sets of dates to use as filters in CALCULATE (DATESYTD, SAMEPERIODLASTYEAR, DATEADD, DATESINPERIOD), or values at a point in time (TOTALYTD, CLOSINGBALANCEMONTH). They take the date column of a date table, or with calendar-based time intelligence a calendar, which also enables the week functions.
This page lists every function in the group, with one example each, in the order you are likely to need them.
Which functions total to date?
| Function | Returns | Example |
|---|---|---|
| TOTALYTD | the expression from the start of the year | TOTALYTD ( [Revenue], 'Date'[Date] ) |
| TOTALQTD | from the start of the quarter | TOTALQTD ( [Revenue], 'Date'[Date] ) |
| TOTALMTD | from the start of the month | TOTALMTD ( [Revenue], 'Date'[Date] ) |
| TOTALWTD | from the start of the week (calendar only) | TOTALWTD ( [Revenue], 'Retail 445' ) |
| DATESYTD | the dates from the start of the year | CALCULATE ( [Revenue], DATESYTD ( 'Date'[Date], "6-30" ) ) |
| DATESQTD | the dates from the start of the quarter | CALCULATE ( [Revenue], DATESQTD ( 'Date'[Date] ) ) |
| DATESMTD | the dates from the start of the month | CALCULATE ( [Revenue], DATESMTD ( 'Date'[Date] ) ) |
| DATESWTD | the dates from the start of the week (calendar only) | CALCULATE ( [Revenue], DATESWTD ( 'Retail 445' ) ) |
In depth: YTD, QTD and MTD.
Which functions shift periods?
| Function | Returns | Example |
|---|---|---|
| SAMEPERIODLASTYEAR | the same dates one year back | CALCULATE ( [Revenue], SAMEPERIODLASTYEAR ( 'Date'[Date] ) ) |
| DATEADD | the dates shifted by n intervals | CALCULATE ( [Revenue], DATEADD ( 'Date'[Date], -1, MONTH ) ) |
| PARALLELPERIOD | the whole period n intervals away | CALCULATE ( [Revenue], PARALLELPERIOD ( 'Date'[Date], -1, YEAR ) ) |
| PREVIOUSDAY | the day before the first date in context | CALCULATE ( [Revenue], PREVIOUSDAY ( 'Date'[Date] ) ) |
| PREVIOUSWEEK | the previous week (calendar only) | CALCULATE ( [Revenue], PREVIOUSWEEK ( 'Retail 445' ) ) |
| PREVIOUSMONTH | all dates of the previous month | CALCULATE ( [Revenue], PREVIOUSMONTH ( 'Date'[Date] ) ) |
| PREVIOUSQUARTER | all dates of the previous quarter | CALCULATE ( [Revenue], PREVIOUSQUARTER ( 'Date'[Date] ) ) |
| PREVIOUSYEAR | all dates of the previous year | CALCULATE ( [Revenue], PREVIOUSYEAR ( 'Date'[Date] ) ) |
| NEXTDAY, NEXTWEEK, NEXTMONTH, NEXTQUARTER, NEXTYEAR | the following period | CALCULATE ( [Forecast], NEXTMONTH ( 'Date'[Date] ) ) |
In depth: year over year.
Which functions return a range?
| Function | Returns | Example |
|---|---|---|
| DATESBETWEEN | the dates from a start to an end date | CALCULATE ( [Revenue], DATESBETWEEN ( 'Date'[Date], DATE ( 2026, 1, 1 ), DATE ( 2026, 3, 31 ) ) ) |
| DATESINPERIOD | the dates from a start, n intervals back or forward | CALCULATE ( [Revenue], DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -12, MONTH ) ) |
In depth: rolling 12 months.
Which functions find period boundaries?
| Function | Returns | Example |
|---|---|---|
| FIRSTDATE | the first date in context | FIRSTDATE ( 'Date'[Date] ) |
| LASTDATE | the last date in context | CALCULATE ( [Units], LASTDATE ( 'Date'[Date] ) ) |
| STARTOFMONTH, STARTOFQUARTER, STARTOFYEAR, STARTOFWEEK | the first date of the period in context | STARTOFMONTH ( 'Date'[Date] ) |
| ENDOFMONTH, ENDOFQUARTER, ENDOFYEAR, ENDOFWEEK | the last date of the period in context | ENDOFYEAR ( 'Date'[Date], "6-30" ) |
FIRSTDATE and LASTDATE return a one-row table, so they work as filters in CALCULATE; MIN and MAX return a value. The week versions need a calendar.
Which functions return balances?
| Function | Returns | Example |
|---|---|---|
| CLOSINGBALANCEMONTH, CLOSINGBALANCEQUARTER, CLOSINGBALANCEYEAR, CLOSINGBALANCEWEEK | the expression at the last date of the period | CLOSINGBALANCEMONTH ( SUM ( Stock[Units] ), 'Date'[Date] ) |
| OPENINGBALANCEMONTH, OPENINGBALANCEQUARTER, OPENINGBALANCEYEAR, OPENINGBALANCEWEEK | the expression at the end of the previous period | OPENINGBALANCEYEAR ( SUM ( Stock[Units] ), 'Date'[Date] ) |
In depth: opening and closing balances. FIRSTNONBLANK and LASTNONBLANK, which find the first or last date with data, are in the filter group but belong with these.
What goes wrong?
- A fact table date column as input. Use the date table's column or a calendar.
- Gaps in the date column. Classic functions throw an error on missing dates; calendars allow them.
- Week functions with a date column. They need a calendar with a week category.
- Nesting with calendars.
PREVIOUSDAY ( PREVIOUSMONTH ( 'Calendar' ) )is not supported; useCALCULATETABLE.
Where can you check this?
- Microsoft Learn: Time intelligence functions (DAX)
- Microsoft Learn: DATESBETWEEN function (DAX)
- Microsoft Learn: ENDOFYEAR function (DAX)
Where do you start?
Learn DATESYTD, SAMEPERIODLASTYEAR, DATEADD and DATESINPERIOD; with CALCULATE they cover nearly all time comparisons. Date and time functions covers building and splitting dates.