Date.IsInCurrentQuarter is a Power Query M function that indicates whether the given date(time) value occurs during the current quarter, 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.IsInCurrentQuarter( dateTime as any ) as nullable logical
Description
Date.IsInCurrentQuarter identifies if a given value (of type date, datetime, or datetimezone) is within the current quarter, according to the system’s date and time.
Examples
Let’s explore two straightforward examples to see how the Date.IsInCurrentQuarter function works.
Identifying Dates in the Current Quarter
Let’s say you have a calendar table and you want to add a column that shows true
for dates that are in the current quarter. You can do this using the Date.IsInCurrentQuarter
function on your [Date]
column.
Date.IsInCurrentQuarter( [Date] ) // Output depends on [Date] column
This function will return true
for any date in the [Date]
column that falls within the current quarter.
For example, if today is July 6, 2024, this function will return true
for all rows with dates between July 1, 2024, and September 30, 2024. Here’s a screenshot taken in the third quarter of 2024:
You can see that dates within the third quarter of 2024 are marked with true
for the current quarter.
Using the Current Date and Time
You can also use Date.IsInCurrentQuarter to check if the current date and time are within the current quarter. This can be done using the DateTime.FixedLocalNow function, which retrieves the current date and time.
// Output: true
Date.IsInCurrentQuarter( DateTime.FixedLocalNow() )
In this example, DateTime.FixedLocalNow() gets the current date and time. The Date.IsInCurrentQuarter function then checks if this date and time are within the current quarter, which will always be true
if today’s date falls within the current quarter.
Related functions
Other functions related to Date.IsInCurrentQuarter are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy