Date.IsInPreviousNQuarters
DateReturns true if the date falls within the previous N calendar quarters.
Syntax
Date.IsInPreviousNQuarters(dateTime as any, quarters as number) as logicalParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | A date, datetime, or datetimezone value to test. |
quarters | number | Yes | The number of quarters back to include. Must be a positive integer. |
Return Value
logical — true 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 | |
|---|---|---|
| 1 | 32 | 7/15/2025 |
| 2 | 35 | 10/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 | |
|---|---|---|---|
| 1 | 28 | 1/15/2025 | FALSE |
| 2 | 32 | 7/15/2025 | TRUE |
| 3 | 42 | 3/8/2026 | FALSE |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks