Date.IsInPreviousQuarter

Updated on

Date.IsInPreviousQuarter is a Power Query M function that indicates whether the given date(time) value occurs during the previous 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.IsInPreviousQuarter( dateTime as any ) as nullable logical

Description

Date.IsInPreviousQuarter identifies if a given value (of type date, datetime, or datetimezone) is within the quarter before the current system quarter. The function will return false for values in the current quarter.

Examples

Let’s explore two straightforward examples to understand how the Date.IsInPreviousQuarter function works.

Identifying Dates in the Previous Quarter

Let’s say you have a calendar table and you want to add a column that shows true for dates within the previous quarter. You can do this by using the Date.IsInPreviousQuarter function on your [Date] column.

Date.IsInPreviousQuarter( [Date] ) // Output depends on [Date] column

This expression returns true for any date in the [Date] column that falls within the previous quarter.

If today is July 6, 2024, this function will return true for all rows with dates between April 1, 2024, and June 30, 2024. Here’s a screenshot showing this:

How to use the Date.IsInPreviousQuarter function in Power Query M

You can see that dates within the previous quarter are marked with true.

Using the Current Date and Time

If we retrieve the current date (generated by DateTime.FixedLocalNow) and shift it back one quarter, we can check if it falls within the previous quarter by using:

// Output: true 
Date.IsInPreviousQuarter( Date.AddQuarters( DateTime.FixedLocalNow(), -1 ) )

Other functions related to Date.IsInPreviousQuarter are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/date-isinpreviousquarter

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy