Date.IsInNextNQuarters is a Power Query M function that indicates whether the given date(time) value occurs during the next number of quarters, as determined by the system. The function returns a boolean value (true or false).
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Date.IsInNextNQuarters(
dateTime as any,
quarters as number,
) as nullable logical
Description
Date.IsInNextNQuarters evaluates whether a given value (of type date, datetime, or datetimezone) is within the next specified number of quarters from the current date and time, excluding the current quarter. It includes a quarters
argument that specifies the number of quarters.
Examples
Let’s explore two straightforward examples to understand how the Date.IsInNextNQuarter function works.
Checking for Dates within the Next N Quarters
Imagine you have a calendar table and you want to add a column that shows true
for dates within the next n quarters. You can do this by using the Date.IsInNextNQuarters function on your [Date]
column, where n represents the number of quarters to check.
Date.IsInNextNQuarters( [Date], n ) // Output depends on [Date] column and n
This expression returns true
for any date in the [Date]
column that falls within the next n quarters.
If you set n to 3 you can use this expression:
Date.IsInNextNQuarters( [Date], 3 )
If today is July 6, 2024, this function will return true
for all rows with dates between October 1, 2024, and June 30, 2025. Here’s a screenshot showing this:
You can see that dates within the next 2 quarters are marked with true
.
Using the Current Date and Time
To test if the quarter following the current system time falls within the next 3 quarters, you can use the following expression:
// Output: true
Date.IsInNextNQuarters( Date.AddQuarters( DateTime.FixedLocalNow(), 1 ), 3 )
Related functions
Other functions related to Date.IsInNextNQuarters are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy