Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Date.IsInCurrentWeek: How to Use It

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Date.IsInCurrentWeek is a Power Query M function that returns true if a given date falls anywhere in the current calendar week (Monday to Sunday, based on the local clock at refresh time). It is not a DAX function and not a custom column you can add from the ribbon without writing a formula: you use it inside a custom column, a filter step, or a conditional column expression. The shortest working version is Date.IsInCurrentWeek([OrderDate]) typed into a Custom Column formula, which gives you a true/false column you can filter to keep only this week's rows.

What You'll Need

  • Power BI Desktop, Excel with Power Query (Data > Get & Transform), or another host that runs the Power Query engine. The steps below use Power BI Desktop; Excel's Power Query Editor has the same formula bar and Custom Column dialog, though menu labels can differ slightly by version and region.
  • A query already loaded with at least one column of Date, DateTime, or DateTimeZone values. Text dates must be converted to a date type first.
  • No add-ins or licences are required. Date.IsInCurrentWeek is part of the standard M library.

Step-by-Step

  1. Open your report in Power BI Desktop and go to Home > Transform data to launch the Power Query Editor. In Excel, select any cell in your table and use Data > From Table/Range, then the Power Query Editor opens.
  2. Find the date column in the Queries pane and click its header so the column is selected. Check the icon to the left of the column name: it should show a calendar icon. If it shows ABC (text), right-click the header, choose Change Type > Date, and confirm the change. If any rows fail to convert, fix those source values first, because Date.IsInCurrentWeek returns an error on text.
  3. With the date column still selected, go to Add Column > Custom Column. The Custom Column dialog opens with a name field and a formula box.
  4. Name the new column something clear, for example IsCurrentWeek.
  5. In the formula box, type Date.IsInCurrentWeek([YourDateColumn]), replacing YourDateColumn with the exact name of your date column as shown in the header, including any spaces inside square brackets. The formula is case-sensitive: Date.IsInCurrentWeek must be written exactly that way.
  6. Click OK. A new true/false column appears at the right of the table. Each row now shows true if that row's date falls in the current Monday-to-Sunday week and false otherwise.
  7. To keep only this week's rows, click the filter arrow on the new column header, tick only true, and click OK. Alternatively, use Home > Keep Rows > Keep Top Rows only after sorting, but the filter is the cleaner method.
  8. If you would rather not add a visible column, you can filter the original date column directly: click the filter arrow, choose Date Filters > Custom Filter (the exact label varies by version), and enter Date.IsInCurrentWeek([YourDateColumn]) in the advanced filter box. The Custom Column route is easier to inspect and debug, so start there.
  9. Click Close & Apply (Home > Close & Apply) to load the result. The true/false evaluation happens at refresh time, so the column re-evaluates each time the query refreshes and the week rolls over.

Common Mistakes

  • Using it on a text column. The function expects a date, datetime, or datetimezone value. A text column that looks like a date will throw Expression.Error: We cannot convert the value to type Date. Convert the type first.
  • Expecting Sunday as the first day. Date.IsInCurrentWeek uses Monday as the start of the week. If your business week starts Sunday, the function will disagree with your reporting calendar by one day at each end.
  • Confusing it with DAX. There is no DAX function with this name. In DAX you would write something like WEEKNUM comparisons or use TODAY() logic. Date.IsInCurrentWeek belongs only in the Power Query (M) layer.
  • Forgetting the square brackets. The column reference must be [OrderDate], not OrderDate or "OrderDate". Quoted text is treated as a literal string and the formula fails.
  • Assuming it filters the source. Adding the column does not remove rows. You must filter on the true value or use the filter step separately.
  • Expecting a static result. The column is recalculated on every refresh. A row that was true last week will be false this week, which is usually what you want but can surprise anyone who saved a snapshot.

Tips

  • Use Date.IsInCurrentWeek together with Date.IsInPreviousWeek and Date.IsInNextWeek to build a rolling three-week view in one query.
  • If you need a week starting on Sunday, add a helper column that shifts the date by one day (Date.AddDays([OrderDate], -1)) and run the function on the shifted value. This keeps the built-in function and avoids hand-written week-number maths.
  • For a dashboard that must stay stable, load the true/false column and let the report layer filter on it, rather than filtering rows out in Power Query. That way you keep history and can compare weeks.
  • Name the custom column with a prefix such as Is so it is obvious it returns true/false and not a date.
  • Test the formula on a small query first. Duplicate the query, keep ten rows, and check the results against a calendar before applying it to a large model.

Troubleshooting

The formula returns an error on some rows. Those rows contain blanks, nulls, or text that could not be converted. Filter out nulls before the step, or wrap the call in try ... otherwise false so bad rows become false instead of breaking the refresh.

The column is all false. Check the data type of the source column and confirm the dates are real dates, not text. Also confirm the machine's clock and time zone, because the current week is calculated from the local system date at refresh time.

The function name is not recognised. You are probably in the wrong editor or typed it into a DAX measure. Date.IsInCurrentWeek is an M function and only works in the Power Query Editor's formula bar or Custom Column dialog.

Results changed after a refresh. That is expected. The function is relative to today, so the set of true rows moves each week. If you need a fixed week, store the date range as parameters instead.

The filter step errors after adding the column. Delete the filter step, re-add the custom column, then apply the filter on the new column's true value. Steps run in order, so a filter placed before the custom column cannot see it.

Frequently Asked Questions

Does Date.IsInCurrentWeek include today?

Yes. Today is always inside the current week, so the function returns true for today's date.

Which day does the week start on?

Monday. The current week runs from Monday through Sunday.

Can I use it in a DAX measure?

No. It is a Power Query M function. In DAX, use date table columns and time intelligence functions instead.

Does it work with DateTime columns?

Yes. It accepts date, datetime, and datetimezone values; the time portion is ignored for the week comparison.

Why does it return false for a date I think is this week?

Usually because the column is text, the date is stored in a different time zone, or the week boundary (Monday) differs from your expectation.

Is there a Sunday-start version?

Not built in. Shift the date by one day with Date.AddDays before calling the function, or calculate the week start manually.