The DATESINPERIOD function returns a set of dates starting from a certain day and covering n intervals of the indicated type backwards or forwards in time.
DATESINPERIOD(
dates,
start_date,
number_of_intervals,
interval
)
- dates: Reference column containing dates.
- start_date: Starting day to consider.
- number_of_intervals: Integer that specifies the number of intervals to add or subtract from the start date.
- interval: Interval to add or subtract: YEAR, QUARTER, MONTH or DAY.
The DATESINPERIOD function returns a table.
If the number of intervals is positive, the indicated interval will be added to the start date that number of times. On the contrary, if it is negative it will be subtracted.
The interval to be considered should not be enclosed in quotation marks.
This DAX function cannot be used in DirectQuery mode.
This example calculates the sales made during the two weeks ending April 23, 2003 (the Sales measure sums the column of sales amounts):