OpenBI Docs Buy

DATEADD

The dates in the filter context moved forward or back by a number of days, months, quarters or years (with a calendar, weeks too).

Group: Time intelligence. Compatible with DAX.

Syntax

DATEADD ( <dates>, <number_of_intervals>, <interval> [, <extension>] [, <truncation>] )
ParameterTypeDescription
datesDatesA column of dates of the model, such as Sales[Month], or the name of a calendar defined in the model.
number_of_intervalsWhole numberHow many intervals to move: forward when positive, back when negative. A fraction is rounded, halves away from zero.
intervalKeywordDAY, MONTH, QUARTER or YEAR; with a calendar that has weeks, WEEK too.
extensionKeyword
optional
With a calendar only: what a shift into a longer period takes. EXTENDING (when left out) adds the rest of the longer period, PRECISE keeps to the same place, ENDALIGNED moves a period's end to the other period's end.
truncationKeyword
optional
With a calendar only: what a shift into a shorter period does with a place it lacks. BLANKS (when left out) leaves it out, ANCHORED takes the period's last date instead.

Returns

Table. The dates of the filter context moved by the intervals, as far as the column holds them.

Remarks

  • Given a column, it reads the dates visible in the current filter context; in a row context, such as ADDCOLUMNS, the row becomes a filter first, so each row sees its own dates.
  • A date moved by months keeps its day where it can, else takes the month's last day: 31 January plus a month is 28 February. When the selection covers the column's first to last date of a month, the whole target month comes back: all of March moved back is all of February.
  • Only dates the column holds come back: a date the move or the period lands on that the column lacks is left out, and when none is left the table is empty. A business day moved onto a weekend is left out (the second example).
  • The selection must be one unbroken run of the column's dates. One with gaps, such as January and March without February, is an error, except on a complete calendar column (one row for every day from the first to the last, no times), where each run moves on its own.
  • To compare with the same period a year before, SAMEPERIODLASTYEAR says the same as DATEADD ( dates, -1, YEAR ); PARALLELPERIOD moves whole months, quarters or years instead.

Examples

The month before and the year before

EVALUATE
ADDCOLUMNS (
    DATESBETWEEN ( Sales[Month], DATE ( 2025, 1, 1 ), DATE ( 2025, 3, 1 ) ),
    "Liters", [Liters sold],
    "Month before", CALCULATE ( [Liters sold], DATEADD ( Sales[Month], -1, MONTH ) ),
    "Year before", CALCULATE ( [Liters sold], DATEADD ( Sales[Month], -1, YEAR ) )
)
ORDER BY Sales[Month]
Sales[Month]LitersMonth beforeYear before
2025-01-01446355041542637
2025-02-01448314463541966
2025-03-01435934483143893

Business days moved back a month

14 to 18 September 2026, a Monday to a Friday. A month back, 15 and 16 August are a weekend that the column does not hold.

EVALUATE
CALCULATETABLE (
    DATEADD ( Prices[Date], -1, MONTH ),
    DATESBETWEEN ( Prices[Date], DATE ( 2026, 9, 14 ), DATE ( 2026, 9, 18 ) )
)
ORDER BY Prices[Date]
Prices[Date]
2026-08-14
2026-08-17
2026-08-18

A selection with a gap

January and March 2025 without February: Sales[Month] is no complete calendar, so the call is an error.

EVALUATE
CALCULATETABLE (
    DATEADD ( Sales[Month], -1, MONTH ),
    FILTER ( ALL ( Sales[Month] ), Sales[Month] = DATE ( 2025, 1, 1 ) || Sales[Month] = DATE ( 2025, 3, 1 ) )
)

Result: an error.

SAMEPERIODLASTYEAR, PARALLELPERIOD, DATESINPERIOD, EDATE, CALCULATE.

Last updated · OpenBI Studio 0.3.74