Power Query Date.IsInCurrentMonth: How to Use It
In this article
Date.IsInCurrentMonth is a Power Query M function that returns true if a given date falls within the current calendar month, based on the system clock at the time the query refreshes. It takes a single date, datetime, or datetimezone value and returns a logical (true/false) result. You can use it in a custom column, a filter step, or a conditional expression to keep only rows dated in the present month. Nothing needs to be installed beyond Power Query itself, which is built into Excel, Power BI Desktop, and Power BI Service dataflows.
What You'll Need
- Power Query Editor open in Excel (Data > Get Data > Launch Power Query Editor) or Power BI Desktop (Home > Transform data). Menu labels can differ slightly by version, device, and region.
- A query that already contains a column of date, datetime, or datetimezone values. The function will not accept text that looks like a date.
- A basic understanding of adding a custom column or editing the formula bar.
Step-by-Step
- Load your data into Power Query. Connect to your source and make sure the date column is typed correctly. Select the column, then use Transform > Data Type and choose Date, Date/Time, or Date/Time/Timezone. If the column shows ABC or 123 icons, the type is wrong and the function will error.
- Decide where you want the result. To keep only current-month rows, you will filter the date column. To tag each row, you will add a custom column. Both approaches are shown below.
- Option A – Filter to the current month. Click the filter arrow on your date column, choose Date Filters > This Month. Power Query writes the equivalent of
Date.IsInCurrentMonth([OrderDate])into the filter step. If you prefer to write it yourself, open the Advanced Editor or the formula bar and add a step such asTable.SelectRows(PreviousStep, each Date.IsInCurrentMonth([OrderDate])). - Option B – Add a true/false column. Go to Add Column > Custom Column. Name it something like IsCurrentMonth. In the formula box enter
Date.IsInCurrentMonth([OrderDate]), replacing OrderDate with your actual column name. Column names are case-sensitive and must be enclosed in square brackets. Click OK. - Check the result. The new column should show true or false. If every row shows false, your date column is probably typed as text or the dates are in a different month than the machine's current date. If you see Error, the column contains nulls or non-date values.
- Handle nulls if needed. Wrap the call to avoid errors on blank rows:
each [OrderDate] <> null and Date.IsInCurrentMonth([OrderDate]). This returns false for nulls instead of an error. - Apply and load. Click Close & Load (Excel) or Close & Apply (Power BI). The filter or column will recalculate each time the query refreshes, so the definition of "current month" moves forward automatically.
Common Mistakes
- Using a text column. Date.IsInCurrentMonth requires a date type. If the column is text, change the data type first, or the function returns an error.
- Forgetting the square brackets. Writing
Date.IsInCurrentMonth(OrderDate)instead ofDate.IsInCurrentMonth([OrderDate])causes a syntax error. - Expecting it to work on a date range. The function tests a single value, not a start and end date. To test a range, compare against
Date.StartOfMonth(DateTime.LocalNow())andDate.EndOfMonth(DateTime.LocalNow())instead. - Assuming it uses a column's own date. It uses the machine or service clock at refresh time. A scheduled refresh on the first of the month may include rows from the new month while the report still shows last month's data until it refreshes.
- Using it in a calculated column in the data model. This is a Power Query M function, not DAX. In the data model use
TODAY()andMONTH()comparisons instead.
Tips
- Use
Date.IsInPreviousMonthandDate.IsInNextMonththe same way for rolling comparisons. - For a report that should always show the month of the latest transaction rather than the calendar month, compare against
Date.StartOfMonth(List.Max(MyTable[OrderDate]))instead of the system clock. - Keep the original date column and add a separate true/false column rather than filtering, so you can reuse the query for other months.
- Name custom columns clearly, such as IsCurrentMonth, so downstream steps and report visuals are easy to read.
Troubleshooting
All rows return false. Check the data type of the date column and confirm the dates actually fall in the current calendar month on the machine running the refresh. A common cause is a text column that looks like a date but is not typed as one.
You get an Expression.Error. This usually means the column contains nulls or values that cannot be converted to a date. Add the null check shown in step 6, or clean the column with Remove Rows > Remove Errors before applying the function.
The filter step will not accept the formula. Make sure you are editing a step that returns a table, and that the each keyword is present in Table.SelectRows. In the Custom Column dialog, do not include each; the dialog adds it for you.
Results change unexpectedly after publishing. In Power BI Service, refreshes run on the service clock, which may be in a different time zone from your desktop. For datetimezone columns, convert to local time first with DateTimeZone.ToLocal if the month boundary matters.
If that did not work, rebuild the step from scratch: remove the custom column or filter, confirm the date type, then re-add the step using the formula bar so you can see the exact M code. As a last resort, close without applying, reopen the query, and repeat the steps.
Frequently Asked Questions
Does Date.IsInCurrentMonth use today's date or the refresh date?
It uses the current date on the system or service performing the refresh. In Power BI Service that is the service clock, which may differ by time zone from your desktop.
Can I use it on a datetime column?
Yes. It accepts date, datetime, and datetimezone values and compares only the date portion.
Why does it return an error on blank rows?
Null values are not valid dates. Guard the call with a null check, or remove null rows before applying the function.
Is there an equivalent in DAX?
Not as a single function. In DAX, compare a date column to TODAY() using YEAR and MONTH, or use time intelligence functions with a marked date table.
Will the result update automatically next month?
Yes, every time the query refreshes. If the query is not set to refresh, the result stays frozen at the last refresh date.
Can I combine it with other conditions?
Yes. Use and and or inside the custom column, for example Date.IsInCurrentMonth([OrderDate]) and [Status] = "Open".