OpenBI Docs Buy

DATESINPERIOD

The dates from a start date over a number of days, months, quarters or years, forward or back (with a calendar, weeks too).

Group: Time intelligence. Compatible with DAX.

Syntax

DATESINPERIOD ( <dates>, <start_date>, <number_of_intervals>, <interval> [, <end_behavior>] )
ParameterTypeDescription
datesDatesA column of dates of the model, such as Sales[Month], or the name of a calendar defined in the model.
start_dateDateThe date the period is counted from; it is included. Blank: the column's first date.
number_of_intervalsWhole numberHow many intervals: forward from the start when positive, back to it when negative. Zero gives nothing.
intervalKeywordDAY, MONTH, QUARTER or YEAR; with a calendar that has weeks, WEEK too.
end_behaviorKeyword
optional
With a calendar only: PRECISE (when left out) keeps to the same place in the other period; ENDALIGNED makes a period's last date reach the other period's last date.

Returns

Table. The column's dates in the period, the start date included.

Remarks

  • Back one month from 15 September covers 16 August to 15 September: the date a month away is not included.
  • Starting on the last day of a month, it counts whole months: back one month from 30 September is all of September.
  • Like DATESBETWEEN, it ignores the filter context on the column; the start date is often MAX ( column ) of the current context, for a moving total.
  • Only dates the column holds come back.

Examples

The last seven days

Seven calendar days back from 14 October 2026: five business days.

EVALUATE
DATESINPERIOD ( Prices[Date], DATE ( 2026, 10, 14 ), -7, DAY )
ORDER BY Prices[Date]
Prices[Date]
2026-10-08
2026-10-09
2026-10-12
2026-10-13
2026-10-14

A moving three-month total

EVALUATE
SUMMARIZECOLUMNS (
    Sales[Month],
    FILTER ( VALUES ( Sales[Month] ), Sales[Month] >= DATE ( 2025, 6, 1 ) && Sales[Month] <= DATE ( 2025, 9, 1 ) ),
    "Liters", [Liters sold],
    "Last 3 months", CALCULATE ( [Liters sold], DATESINPERIOD ( Sales[Month], MAX ( Sales[Month] ), -3, MONTH ) )
)
ORDER BY Sales[Month]
Sales[Month]LitersLast 3 months
2025-06-0159243153009
2025-07-0164419173110
2025-08-0159266182928
2025-09-0149761173446

From a month's last day

EVALUATE
VAR Days = DATESINPERIOD ( Prices[Date], DATE ( 2026, 9, 30 ), -1, MONTH )
RETURN
    ROW ( "Days", COUNTROWS ( Days ), "From", MINX ( Days, Prices[Date] ), "To", MAXX ( Days, Prices[Date] ) )
DaysFromTo
222026-09-012026-09-30

DATESBETWEEN, DATEADD, CALCULATE, MAX.

Last updated · OpenBI Studio 0.3.74