Date.IsInPreviousNQuarters

Date

Returns true if the date falls within the previous N calendar quarters.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Date.IsInPreviousNQuarters(dateTime as any, quarters as number) as logical

Parameters

NameTypeRequiredDescription
dateTimeanyYesA date, datetime, or datetimezone value to test.
quartersnumberYesThe number of quarters back to include. Must be a positive integer.

Return Value

logicaltrue if the date falls within the N quarters before the current quarter, false otherwise.

Remarks

Date.IsInPreviousNQuarters returns true if the input date falls within the N complete calendar quarters preceding the current quarter. The current quarter itself is not included; use Date.IsInCurrentQuarter to also match the current quarter. The function is re-evaluated on each query refresh.

For example, if today is in Q1 2026 and quarters = 2, it matches any date in Q3 2025 or Q4 2025.

Examples

Example 1: Filter sales from the previous 2 quarters

Table.SelectRows(
    Sales,
    each Date.IsInPreviousNQuarters([OrderDate], 2)
)
Result
OrderID
OrderDate
1327/15/2025
23510/20/2025

Example 2: Flag orders from the prior 4 quarters

Table.AddColumn(
    Sales,
    "PriorYear", each Date.IsInPreviousNQuarters([OrderDate], 4), type logical
)
Result
OrderID
OrderDate
PriorYear
1281/15/2025FALSE
2327/15/2025TRUE
3423/8/2026FALSE

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks