Power Query Date.IsInCurrentQuarter: How to Use It
In this article
Date.IsInCurrentQuarter is a Power Query M function that returns true if a given date falls within the current calendar quarter (Q1: Jan–Mar, Q2: Apr–Jun, Q3: Jul–Sep, Q4: Oct–Dec) based on today's date. To use it, you need Power Query available (in Excel, Power BI, or another Microsoft tool) and a column or value of type date, datetime, or datetimezone. The function takes one argument: the date to test. It returns a logical value (true/false) and does not require any additional setup.
What You'll Need
- Power Query Editor open in Excel, Power BI Desktop, or another Microsoft tool that supports M (e.g., Analysis Services, Dataflows).
- A query with at least one column containing date, datetime, or datetimezone values. If your column is text, convert it to a date type first.
- Basic familiarity with adding a custom column or writing an M expression.
Step-by-Step
- Open Power Query Editor. In Excel, go to Data > Get Data > Launch Power Query Editor. In Power BI Desktop, click Transform Data on the Home ribbon. Menu labels may differ slightly by version and platform.
- Load or create a query with a date column. For example, import a table that has an OrderDate column. Ensure the column's data type is Date, DateTime, or DateTimeZone. You can check the type icon in the column header; if it shows ABC, it's text. Change it via the icon or the Transform tab > Data Type.
- Add a custom column. On the Add Column tab, click Custom Column. In the dialog, give the new column a name, such as IsCurrentQuarter.
- Enter the formula. In the formula box, type:
Date.IsInCurrentQuarter([OrderDate])(replace OrderDate with your actual column name). The function is case-sensitive:Date.IsInCurrentQuarterwith capital D, I, C, Q. Use square brackets around the column name. - Click OK. Power Query adds the column and shows true or false for each row. The calculation uses the current date at the time of refresh; it does not update automatically until the query is refreshed.
- Filter or use the result. You can filter the new column to keep only true rows, or use it in further calculations. For example, add another custom column with
if [IsCurrentQuarter] then "Current" else "Other". - Close and load. When done, click Close & Load (Excel) or Close & Apply (Power BI) to output the result.
Common Mistakes
- Using a text column. If the column is text, the function returns an error. Convert the column to Date type first. You can use Date.FromText or change the data type.
- Forgetting square brackets. Column references must be in square brackets, e.g., [OrderDate], not OrderDate.
- Case errors. M is case-sensitive. Date.isincurrentquarter (all lowercase) will not work. Use exact capitalization: Date.IsInCurrentQuarter.
- Assuming it uses a fixed quarter. The function uses the current date on the system running the query. If you refresh on a different date, results change. For a fixed quarter, use explicit date comparisons instead.
- Using it on a null value. If the date column contains nulls, the function returns null, not false. Handle nulls with a conditional if needed.
- Expecting it to work on a column of type Any. The argument must be date, datetime, or datetimezone. If the column is Any, convert it first.
Tips
- To test multiple dates, you can use the function in a custom column and then filter.
- If you need the current quarter as a number (1–4), use
Date.QuarterOfYear(DateTime.LocalNow()). - For a fixed quarter relative to a specific date, use Date.QuarterOfYear and compare, e.g.,
Date.QuarterOfYear([OrderDate]) = Date.QuarterOfYear(#date(2024,1,1)). - Combine with other date functions like Date.IsInCurrentYear or Date.IsInCurrentMonth for broader filters.
- Remember that the function uses the local date of the machine running the query. In scheduled refresh scenarios, ensure the server's date is correct.
- Use the formula bar to edit the step if you need to change the column name later.
Troubleshooting
If you see an error like "We cannot convert the value null to type Logical" or "Expression.Error: The name 'Date.IsInCurrentQuarter' wasn't recognized", check the following:
- Function name spelling: Ensure exact capitalization and no typos. It is Date.IsInCurrentQuarter, not Date.IsInCurrentQuarter (with a space) or Date.IsInCurrentQuarter().
- Column data type: Select the column and confirm the type icon shows a calendar, not ABC. If it's text, use Transform > Data Type > Date.
- Null values: If the column has nulls, the function returns null. Wrap with
if [Column] = null then false else Date.IsInCurrentQuarter([Column]). - Refresh date: If results seem wrong, check the system date on the machine running Power Query. The function uses that date, not a date stored in the query.
- Power Query version: This function is available in recent versions of Power Query for Excel and Power BI. If it's missing, update your software.
If the function still fails, try creating a simple test query with a single date value to isolate the issue.
Frequently Asked Questions
What does Date.IsInCurrentQuarter return for a date in the current quarter?
It returns true if the date falls in the same calendar quarter as today's date, otherwise false. For example, if today is February 15, 2025 (Q1), then January 10, 2025 returns true, but April 1, 2025 returns false.
Can I use Date.IsInCurrentQuarter with a datetime column?
Yes, the function accepts date, datetime, and datetimezone values. It ignores the time portion and compares only the date part.
Does the function work in Power BI Desktop and Excel?
Yes, it is part of the standard M library available in both. The steps to add a custom column are similar, though menu locations may vary slightly.
How do I handle null values when using this function?
The function returns null for null input. To treat nulls as false, use a conditional expression: if [DateColumn] = null then false else Date.IsInCurrentQuarter([DateColumn]).
Is there a way to get the current quarter number instead?
Yes, use Date.QuarterOfYear(DateTime.LocalNow()) to return 1–4. You can also use Date.QuarterOfYear([YourDate]) for a specific date.
Why does my custom column show errors after adding the function?
Common causes are text data type in the date column, incorrect column name spelling, or missing square brackets. Check the data type and formula syntax.