Power QueryExercises

Calendar table with closure days

Generate a 2026 date table in M and flag the company's closure days from a small CSV. No external date source needed.

intermediate · Skills: List.Dates, Date functions, Lookups with List.Contains · Updated 2026-11-04

Data files

  • closure-days.csv — Date and Reason for seven fictional company closure days in 2026.Download CSV (208 B)

Queries

Validated in the Power Query Exercises simulator against the files above. Paste them into Excel or Power BI yourself; the header comments explain each source binding.

Calendar 2026 calendar-2026.pq

Download .pq

One row per day with month, ISO-style week start, weekend and closure flags. Returns 365 rows: Date, Month, MonthName, WeekStart, IsWeekend, IsClosure.

// Calendar 2026
// Pack: Calendar table with closure days (Power Query Exercises, https://powerqueryexercises.com/downloads/calendar-closure-days)
//
// Source bindings
// In the Power Query Exercises simulator each name below is bound directly to a pack file. In Excel or
// Power BI Desktop the first steps of this query do that binding instead:
//   ClosureDays    the pack file closure-days.csv -> File.Contents(PackFolder & "closure-days.csv")
// Set PackFolder to the folder where you extracted the pack (keep the trailing backslash).
//
// Validated in the Power Query Exercises simulator (engine 0.1.0) against this pack's files; it returns
// 365 rows with columns Date, Month, MonthName, WeekStart, IsWeekend, IsClosure.
// It has not been run in Excel or Power BI by us. This is query text, not a ready-to-refresh workbook.
// Independent practice material; not affiliated with or endorsed by Microsoft.
let
    PackFolder = "C:\PQE\calendar-closure-days\",
    ClosureDays = File.Contents(PackFolder & "closure-days.csv"),
Closures = Table.TransformColumnTypes(Table.PromoteHeaders(Csv.Document(ClosureDays, [Delimiter=",", Encoding=65001, QuoteStyle=QuoteStyle.Csv])), {{"Date", type date}}),
    #"Dates" = List.Dates(#date(2026, 1, 1), 365, #duration(1, 0, 0, 0)),
    #"Table" = Table.FromList(#"Dates", Splitter.SplitByNothing(), {"Date"}),
    #"Typed" = Table.TransformColumnTypes(#"Table", {{"Date", type date}}),
    #"Month" = Table.AddColumn(#"Typed", "Month", each Date.Month([Date]), Int64.Type),
    #"Month name" = Table.AddColumn(#"Month", "MonthName", each Date.ToText([Date], "MMM"), type text),
    #"Week start" = Table.AddColumn(#"Month name", "WeekStart", each Date.StartOfWeek([Date], Day.Monday), type date),
    #"Weekend" = Table.AddColumn(#"Week start", "IsWeekend", each Date.DayOfWeek([Date], Day.Monday) >= 5, type logical),
    #"Closed" = Table.AddColumn(#"Weekend", "IsClosure", each List.Contains(Closures[Date], [Date]), type logical)
in
    #"Closed"

Follow along in a host

Follow along in Excel

  1. Download the pack and extract the zip, for example to C:\PQE\<pack name>\.
  2. In Excel (Microsoft 365 or 2016+ on Windows), go to Data → Get Data → From Other Sources → Blank Query.
  3. In the Power Query Editor choose Home → Advanced Editor, select everything and paste the contents of the .pq file.
  4. Change the PackFolder line to the folder you extracted to, then choose Done.
  5. If Excel asks about privacy levels or file access, allow access to that folder. Then choose Home → Close & Load.

Follow along in Power BI Desktop

  1. Download the pack and extract the zip.
  2. In Power BI Desktop choose Home → Transform data to open the Power Query Editor, then Home → New Source → Blank Query.
  3. Choose Home → Advanced Editor, paste the contents of the .pq file and change the PackFolder line to your folder.
  4. Choose Done, check the preview against the expected rows in the query header, then Close & Apply.

Then try this

  1. Change 365 to cover several years (remember leap years) and add a Year column.
  2. Add a closure day to the CSV and refresh: IsClosure flips for that date.

Related lessons

Original fictional data, free to use for learning and teaching. Power Query Exercises is not affiliated with or endorsed by Microsoft.