DAX DATEADD function
Returns the dates in view, shifted by a number of days, months, quarters or years.
DATEADD moves the period in view forwards or backwards. With -1 and MONTH it gives the previous month, the base of month-over-month measures.
Syntax
DATEADD(<dates>, <number_of_intervals>, <interval>)| Argument | Required | Description |
|---|---|---|
| dates | Required | The date column of your date table. |
| number_of_intervals | Required | How many intervals to move: negative goes back. |
| interval | Required | DAY, MONTH, QUARTER or YEAR. |
Returns: A table of dates, used as a filter.
Examples
Calculated on the free practice data (table financials), with [Total Sales] = SUM(financials[Sales]) and [Total Profit] = SUM(financials[Profit]).
1. Previous month's sales
Sales PM = CALCULATE([Total Sales], DATEADD(Dates[Date], -1, MONTH))| Month Year | Sales PM |
|---|---|
| Sep 2013 | (blank) |
| Oct 2013 | 4,484,000.03 |
| Nov 2013 | 9,295,611.10 |
| Dec 2013 | 7,267,203.30 |
| Jan 2014 | 5,368,441.08 |
September 2013 is the first month with data, so it has no previous month.
Good to know
- Month-over-month change: DIVIDE([Total Sales] - [Sales PM], [Sales PM]).
Related functions
Official reference: DATEADD function on Microsoft Learn