Skip to content

Monthly to weekly budget

Finance teams often prepare budgets by month, but the actual sales arrive by week, so the budget has to be restated at the same weekly grain before the two can be compared.

The usual manual fix is to divide each month’s budget by 4 for a four-week month, or by 5 for a five-week month. This page does the same thing in Power Query, so the weekly budget rebuilds itself whenever the budget or the calendar changes.

The approach has six parts:

  1. Use a weekly 5-4-4 calendar as a mapping table. It maps each week to its month, so it shows which months have four weeks and which have five. Two extra columns, YYMM for the month and YYWW for the week, give the keys for the joins that follow.
  2. Load the Monthly Budget into Power Query as a connection only.
  3. Build a Week Count query from the calendar, which gives the number of weeks in each month.
  4. Merge the Week Count query into the Monthly Budget query, so each month’s budget sits beside its number of weeks.
  5. Merge the weekly calendar into that extended budget query. Because each month matches four or five weeks, the merge repeats each month’s budget line once per week, which gives a table with one row per week. Each row still carries the whole month’s budget, though.
  6. Divide each row’s monthly budget by the number of weeks in its month, which gives the Weekly Budget.

Add two custom columns to it, YYWW and YYMM, with the M code below.

YYWW:

= Number.FromText(
Text.End(
Number.ToText(
Date.Year([Week Ending])), 2)) * 100 +
[Fin Week]

YYMM:

= Number.FromText(
Text.End(
Number.ToText(
Date.Year([Week Ending])), 2)) * 100 +
[Fin Month]

Each formula takes the last two digits of the year, multiplies them by 100 and adds the week or month number, so week 3 of 2020 becomes 2003 and month 1 becomes 2001.

Loaded into Excel with the two new columns, the calendar looks like this:

The weekly calendar loaded to an Excel table, with Week Ending, WeekID, Fin Week, Week of Quarter, YearID, Fin Year, MonthID, Fin Month, Month Name, YYWW and YYMM columns

  • Load the monthly budget table into Power Query.
  • Choose Close & Load To and load the query as Only Create Connection.

The budget has one row per month, keyed by YYMM:

An Excel table of the monthly budget, with YYMM from 2001 to 2012 and a Budget for each month

The next query counts the weeks in each month.

  • In the Queries & Connections pane, right-click the weekly calendar query and choose Reference.

The right-click menu on the 554 Calendar Weekly query, with Reference highlighted

  • In the new query, click Group By, group on YYMM, and add a column called Count with the operation Count Rows.

The Group By dialog grouping on YYMM, with a new column Count using Count Rows

The query now returns the number of weeks in each month:

The Week Count query, with each YYMM and its Count of 4 or 5 weeks

  • Name the query Week Count.
  • Close & Load it as Only Create Connection.

4. Merge the week count into the monthly budget

Section titled “4. Merge the week count into the monthly budget”

The budget query needs each month’s week count beside its budget.

  • Open the Monthly Budget query in the Power Query Editor.
  • On the Home tab, click Merge Queries.
  • In the Merge dialog, choose the Week Count table, match the two tables on YYMM, and keep the join kind as Left Outer.

The Merge dialog joining Monthly_Budget to Week Count on YYMM with a left outer join, matching 12 of 12 rows

  • Expand the new column, ticking only Count:

The expand menu on the Week Count column, with only Count ticked

Each month’s budget now has its week count beside it:

The Monthly Budget query with YYMM, Budget and Count columns

5. Merge the weekly calendar into the budget

Section titled “5. Merge the weekly calendar into the budget”

Carry on editing the same query, and click Merge Queries again. Choose the weekly calendar, make another Left Outer join, and match the YYMM columns of the two tables.

The Merge dialog joining Monthly_Budget to 554 Calendar Weekly on YYMM with a left outer join

The merged budget table, with each month’s YYMM, Budget and Count repeated against each of its YYWW weeks

Each row now stands for one week, but its Budget is still the month’s total. Add a custom column called Weekly Budget that divides the Budget by the Count of weeks.

The Custom Column dialog creating Weekly Budget as [Budget] / [Count]

  • Finally, Close & Load this query to Excel as a Table, rather than as a connection only.

The weekly budget then loads into Excel like this:

The weekly budget in Excel, where a 50,000 month of five weeks gives 10,000 a week and a 45,000 month of four weeks gives 11,250

In the Power Query Editor, the Query Dependencies button on the View tab shows how the queries connect:

The Query Dependencies view, where 554 Calendar feeds 554 Calendar Weekly, which feeds Week Count, and Week Count and the current workbook feed Monthly_Budget