Skip to content

Creating a 554 Calendar

Many companies, especially retailers, do not report on calendar months. They use a calendar made of whole weeks instead, such as a 4-4-5 calendar, where each quarter has a month of four weeks, another of four and a last of five.

These calendars differ from company to company in a few ways:

  1. the month in which the financial year starts
  2. the day on which each week starts
  3. how the spare day is handled, because 365 days make 52 weeks with one day left over

This page builds one example, which follows these rules:

  1. The financial year starts on the Monday closest to 1 January.
  2. Each quarter’s months have five, four and four weeks, so January has five weeks, February four and March four, and the pattern then repeats.
  3. Its weeks, months and years are the financial weeks, months and years that the financial data is reported in.
  • Generate a list of dates that starts on the first day of the financial year:
= List.Dates(#date(2019,12,30), 1096, #duration(1,0,0,0))
  • Convert the list to a table and rename its column Dates.
  • Add an index column called ID that starts from 1.

The Dates column starting on 30/12/2019 beside an ID column counting up from 1

The 5-4-4 pattern repeats every 13 weeks, so each week needs its own number before it can be assigned to a month.

  • Add a custom column called WeekID that divides the ID by 7 and rounds up, using Number.RoundUp. Every week in the whole calendar then has its own number.

The Custom Column dialog creating WeekID with Number.RoundUp([ID]/7)

  • Add a Fin Week column with the formula below, which numbers the weeks from 1 to 52 within each year.

The Custom Column dialog creating Fin Week from WeekID, using Number.RoundUp and 52

  • Add a Week of Quarter column, which counts from 1 to 13 and then starts again.

The formula subtracts a multiple of 13 from the WeekID. In the first 13 weeks it subtracts 0 × 13, so weeks 1 to 13 keep their numbers. In the next 13 weeks it subtracts 1 × 13, so weeks 14 to 26 become 1 to 13 again, and so on for every later quarter.

The Custom Column dialog creating Week of Quarter from WeekID, using Number.RoundUp and 13

  • Add a YearID column, which is 1 for the first year, 2 for the second and so on. It divides the WeekID by 52 and rounds up, so that each block of 52 weeks gets its own year number.

The Custom Column dialog creating YearID with Number.RoundUp([WeekID]/52)

Week 53 therefore starts the second year, and it also starts on a Monday.

Each financial year is named after the calendar year that its middle falls in. A 52-week year is 364 days long, so the middle of the first year is 182 days after the start date, and each later year’s middle is another 364 days on. The formula finds that date and takes its year:

Date.Year(Date.AddDays(#date(2019,12,30), ([YearID] - 1) * 364 + 182))

A calendar that starts on 30 December 2019 gives 2020 for its first year, and one that starts on 2 January 2023 gives 2023, so the name is right whether the year starts just before or just after 1 January.

The screenshot shows an earlier, simpler formula, which adds the YearID to the start date’s year. That works only when the year starts in late December, since a start in early January would be named after the following year.

The Custom Column dialog creating Fin Year as Date.Year(#date(2019,12,30)) + [YearID]

The Week of Quarter column says which month of its quarter a week falls in. Weeks 1 to 5 are in the first month, weeks 6 to 9 in the second and weeks 10 to 13 in the third, and this holds for every quarter.

The MonthID column uses an if statement with one test for each of those three ranges. The number of quarters already completed is the WeekID divided by 13, rounded up, less 1. The formula multiplies that by 3, which gives the number of months already completed, and adds 1, 2 or 3 according to the range the week falls in.

The Custom Column dialog creating MonthID with an if statement over three ranges of Week of Quarter

  • Add a Fin Month column from the MonthID. It works like the Week of Quarter column, but with 12 in place of 13, so it counts from 1 to 12 within each year.

The Custom Column dialog creating Fin Month from MonthID, using Number.RoundUp and 12

Because this financial year starts in January, the financial month number is the same as the calendar month number, so it can produce the month name directly. The formula builds a date from the year and month, and the day does not matter, because only the month’s name is extracted.

The Custom Column dialog creating Month Name with Date.ToText and the format MMM

  • Finally, add a Day Name column.

The Custom Column dialog creating Day Name with Date.ToText([Dates], “ddd”)

  • In the Queries pane, right-click the query and choose Duplicate.
  • Edit the copy so that it becomes a function, as in the code below:
let myCalendar = (YearStartDate as date) =>
let
Source = List.Dates(YearStartDate, 1096, #duration(1,0,0,0) ),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Dates"}}),
#"Added Index" = Table.AddIndexColumn(#"Renamed Columns", "ID", 1, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "WeekID", each Number.RoundUp([ID]/7)),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Fin Week", each [WeekID] - (Number.RoundUp([WeekID]/52) - 1) * 52),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Week of Quarter", each [WeekID] - (Number.RoundUp([WeekID]/13) - 1) * 13),
#"Added Custom3" = Table.AddColumn(#"Added Custom2", "YearID", each Number.RoundUp([WeekID]/52)),
#"Added Custom4" = Table.AddColumn(#"Added Custom3", "Fin Year", each Date.Year(Date.AddDays(YearStartDate, ([YearID] - 1) * 364 + 182))),
#"Added Custom5" = Table.AddColumn(#"Added Custom4", "MonthID", each if ([Week of Quarter] >=1 and [Week of Quarter] <=5)
then ((Number.RoundUp([WeekID]/13)-1)*3)+1
else if ([Week of Quarter] >=6 and [Week of Quarter] <=9)
then ((Number.RoundUp([WeekID]/13)-1)*3)+2
else if ([Week of Quarter] >=10 and [Week of Quarter] <=13)
then ((Number.RoundUp([WeekID]/13)-1)*3)+3
else null),
#"Added Custom6" = Table.AddColumn(#"Added Custom5", "Fin Month", each [MonthID] - (Number.RoundUp([MonthID]/12) - 1) * 12),
#"Added Custom7" = Table.AddColumn(#"Added Custom6", "Month Name", each Date.ToText(#date([Fin Year], [Fin Month],1), "MMM")),
#"Added Custom8" = Table.AddColumn(#"Added Custom7", "Day Name", each Date.ToText([Dates], "ddd"))
in
#"Added Custom8"
in
myCalendar

Once the function is saved, the editor shows its parameter box:

The function’s Enter Parameter box with a YearStartDate field and Invoke and Clear buttons

Click Invoke, and a dialog asks for the start date.

The Enter Parameter dialog asking for YearStartDate

Enter a start date such as 02/01/2023, which is the Monday closest to 1 January 2023, and click OK. Power Query generates a calendar table of the 1096 days from that date.

Each calendar table can also give a weekly calendar with one row per week.

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

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

  • In the new query, filter the Day Name column to keep only Sundays, which are the last day of each week.

The filter list on the Day Name column with only Sun ticked

Then tidy the result:

  • Remove the Day Name column, which no longer tells you anything.
  • Rename the Dates column to Week Ending.
  • Remove the ID column, which now reads 7, 14, 21 and so on.

The weekly calendar then looks like this:

The weekly calendar with a Week Ending date each Sunday and its WeekID, Fin Week, Week of Quarter, YearID, Fin Year, MonthID and Fin Month