Cheat Sheets/Power BI/DATESINPERIOD
DAX function

DATESINPERIODDAX function reference

A rolling window of dates.

Syntax

dax
DATESINPERIOD(<dates>, <start_date>, <number_of_intervals>, <interval>)

Examples

dax
CALCULATE(SUM(Sales[Amount]), DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -3, MONTH))
Rolling 3-month value
dax
CALCULATE(SUM(Sales[Amount]), DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -12, MONTH))
Trailing 12-month sales, anchored to the last date in context

DATESINPERIOD supplies the window of dates and AVERAGEX evaluates the daily total for each before averaging.

dax
AVERAGEX(DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -7, DAY), CALCULATE(SUM(Sales[Amount])))
A 7-day moving average of daily sales

Common mistakes & gotchas

Related DAX functions

From Time intelligence

Used in these tutorials

← Back to the Power BI (DAX) cheat sheet