Power Query Date.WeekOfMonth: How to Get Week Number
In this article
Power Query's Date.WeekOfMonth returns the week number of a date within its own month, as an integer from 1 to 6. It is the right function when you need a "which week of the month" column — for payroll cycles, retail periods, rent schedules, or reporting by week-within-month — rather than a week number that runs continuously across the year. It is built into Power Query M, so it works the same in Power BI, Excel, and any other tool that hosts the Power Query Engine; there is no add-in to install. The one decision you make up front is which day you want the week to start on, because that choice changes the result.
What You'll Need
- A date column that Power Query recognizes as a date type (not text and not a number).
- Access to Power Query: in Excel, Data > Get Data on the ribbon; in Power BI, Transform Data on the Home tab.
- Enough familiarity to open the Power Query Editor and add a custom column. No coding experience is required beyond typing one function call.
Step-by-Step
- Load your table into Power Query. In Excel, select a cell in your table and choose Data > Get Data, then point at your source. Your data must pass through Power Query, not a plain copied range, or there will be nowhere to add the calculation.
- Confirm the column is a date. Click the small type icon at the left of the column header. If it shows ABC or 123 instead of a calendar icon, change it to Date. A text column full of values like "05/12/2026" will throw an error when you apply the date function.
- Add a custom column. On the Add Column tab, click Custom Column. On desktop Excel and Power BI this wording is consistent; labels can differ slightly by version or region, so if you do not see it, look for the same option under the Add Column menu.
- Name the new column something readable, such as Week of Month, in the first box of the custom column dialog.
- Enter the formula. In the formula box, type the function and point it at your date column, with the column name in square brackets and quoted as shown by the dialog. The pattern is:
Date.WeekOfMonth([Order Date]). If your column name contains spaces, you still reference it the way the dialog auto-inserts it when you double-click the column in the list. - Choose whether you need a specific start day. If weeks in your organization start on Monday, add the second argument:
Date.WeekOfMonth([Order Date], Day.Monday). Without it, the function uses its default first-day setting, which may not match your calendar; see the Common Mistakes section. - Check the preview. Click OK and scan the new column. Every row should show a number from 1 to 6. Blank rows will show errors, so filter them out or clean them first.
- Set the type. Click the type icon on the new header and choose Whole Number so it sorts numerically rather than as text in your report.
- Rename and close. Rename the query if needed, then use Home > Close & Load (Excel) or Close & Apply (Power BI) to write the result to your workbook or model.
Common Mistakes
- Assuming weeks start on Monday by default. The default first day is not guaranteed to match your region or your company calendar. If the numbers look one off from what colleagues expect, add the start-day argument explicitly so the result is predictable and documented.
- Leaving the date column as text. The most common error message people hit is a type error on the whole column. Fix the type before adding the function, not after.
- Confusing this with week-of-year. Date.WeekOfMonth restarts at 1 every month. If you need a continuous week number across the year, use Date.WeekOfYear instead. Mixing them up produces misleading period labels.
- Expecting weeks to split neatly. Because a month does not contain whole weeks, the first and last weeks are usually partial. A date early in the month may be week 1 even though the business calls it "week 5 of the previous period." Decide which convention your reports use and state it in the header.
- Forgetting that the start-day changes counts. A month can produce a different number of week buckets depending on the start day, so the same dataset can show up to six buckets under one setting and a different split under another.
- Adding the column to the wrong query step. Custom columns are added to the query you are in. If you are working on a reference query, the step lands there, which is usually what you want — but check the query name in the left pane before assuming.
Tips
- Keep a date table. Rather than adding this column to a large fact table, create a small date table with one row per day and add the week-of-month column there. It stays reusable and keeps the fact table lean.
- Pair it with year and month. "Week 2" alone is ambiguous across months. Add Year and Month columns so a report label reads 2026-03 Week 2.
- Document the start day. Add a note in the query name or a column comment stating which day the week begins, so future editors do not guess.
- Use it for period comparisons. Week-of-month is handy for comparing "first week of each month" or building 4-4-5 style retail periods, because it groups dates into comparable monthly buckets.
- Test with known dates. Before trusting a large load, type a few dates whose week number you can reason about and check the output against a calendar. It takes a minute and catches start-day problems early.
Troubleshooting
If every row shows an error, the column is almost certainly text or contains blanks. Change the type to Date, then filter out nulls or replace them before applying the function.
If the numbers look wrong by one, the start day is the culprit. Add Day.Monday (or whichever day your calendar uses) as the second argument and compare again.
If the column will not sort correctly, it is still typed as text. Set it to Whole Number.
If the function is not recognized, check the spelling and the capital letters: M is case-sensitive, so Date.WeekOfMonth needs exactly that capitalization. Also confirm you are in the custom column formula box, not a text field.
If you see six weeks in a month you expected five, that is normal when the month starts late in the week. Partial weeks still count. If your reports require exactly four or five buckets, you will need custom grouping logic rather than this function alone.
If results differ between two reports, one may be using week-of-year and the other week-of-month, or they may use different start days. Compare the formulas, not the column headers.
Frequently Asked Questions
Is Date.WeekOfMonth available in both Excel and Power BI?
Yes. Both host the Power Query M engine, so the function is identical. Only the surrounding menu labels differ between the two apps.
Does it return weeks of the year or weeks of the month?
Weeks of the specific month, numbered from 1 up to 6. For a year-wide number, use Date.WeekOfYear.
How do I make Monday the first day of the week?
Pass Day.Monday as the second argument: . You can substitute any day constant your calendar uses.
Why does one month show six weeks?
A month spans parts of several calendar weeks, so any partial week at the start or end adds a bucket. Six is expected for some months and is not an error.
What happens with blank dates?
Blanks produce errors in the new column. Filter them out or fill them before adding the function.
Can I use it in a calculated column outside Power Query?
This is a Power Query M function. In DAX you would use a different set of week functions, so keep this calculation in the query or a date table built in Power Query.