Power Pivot & DAX course · Lesson 11 of 16

Building a calendar (date) table for Power Pivot

Create a proper date table for the Data Model: Date Table › New, SEQUENCE or Power Query, calculated columns, Sort by Column and Mark as Date Table.

Intermediate 18 min read

Almost every report slices by time: months, quarters, years, weekdays, fiscal periods. You could add Year and Month calculated columns to the Sales table, but that leads to trouble: months with no sales vanish, time-intelligence functions misbehave, and every fact table needs its own copy. The professional answer is a calendar table (also called a date table or date dimension): one row per day, related to every date column in your facts. This lesson builds one and prepares it for Time intelligence in DAX: TOTALYTD, SAMEPERIODLASTYEAR, DATEADD, DATESINPERIOD.

What makes a proper calendar table

  • One row per day, with no gaps, from the first day of the earliest year to the last day of the latest year in your data.
  • A Date column of data type Date, unique on every row and with no time portion (midnight).
  • Descriptive columns for grouping: Year, Quarter, Month name and number, Weekday, perhaps fiscal year and week.
  • A relationship from each fact table's date column to 'Calendar'[Date].
  • It is marked as a date table so DAX knows which column holds the dates.

Three ways to create it

Option 1: let Power Pivot build it

In the Power Pivot window choose Design › Date Table › New. Power Pivot looks at the date columns in your model and creates a table called Calendar covering complete years, with ready-made columns such as Year, Month Number, Month and Day Of Week. When your data later extends into a new year, Design › Date Table › Update Range extends it. This is the fastest option, and the table is automatically marked as a date table.

Option 2: a worksheet table with SEQUENCE

In Excel 365 or 2021, put the header Date in A1 of a new sheet and in A2 enter =SEQUENCE(DATE(2026,12,31)-DATE(2025,1,1)+1,1,DATE(2025,1,1)). SEQUENCE spills 730 consecutive dates for 2025 and 2026. Because an Excel table cannot contain a spilled formula, copy the dates and paste them as values (Home › Paste › Values), format them as dates, press Ctrl+T, name the table Calendar and choose Power Pivot › Add to Data Model. You control every detail, but you must extend the list yourself each year.

Option 3: Power Query

Power Query can generate the list of dates from a start and end date (for example the earliest and latest order dates) and refresh it automatically, which is the most robust option for workbooks that are updated for years. The Power Query course on this site covers the technique; load the query with Only Create Connection and Add this data to the Data Model, as shown in Importing data into the Data Model: tables, Power Query and databases.

Note. Power BI users often write CALENDAR or CALENDARAUTO to create a calculated table in DAX. Excel's Power Pivot does not support calculated tables, so in Excel the calendar must come from one of the three options above.

Adding the descriptive columns

Whichever option you used, add or check these calculated columns in the Calendar table (Data View › Add Column):

DAX
Year = YEAR ( 'Calendar'[Date] )
MonthNo = MONTH ( 'Calendar'[Date] )
Month = FORMAT ( 'Calendar'[Date], "mmm" )
Quarter = "Q" & ROUNDUP ( MONTH ( 'Calendar'[Date] ) / 3, 0 )
YearMonth = YEAR ( 'Calendar'[Date] ) * 100 + MONTH ( 'Calendar'[Date] )
Month Year = FORMAT ( 'Calendar'[Date], "mmm yyyy" )
WeekdayNo = WEEKDAY ( 'Calendar'[Date], 2 )
Weekday = FORMAT ( 'Calendar'[Date], "ddd" )
Is Weekend = WEEKDAY ( 'Calendar'[Date], 2 ) > 5
One calculated column per line; in Power Pivot type only the part after the column name, starting with =
ABCDEF
1DateYearMonthNoMonthQuarterWeekday
22026-01-0120261JanQ1Thu
32026-01-0220261JanQ1Fri
42026-01-0320261JanQ1Sat
52026-01-0420261JanQ1Sun
62026-01-0520261JanQ1Mon
72026-01-0620261JanQ1Tue
82026-01-0720261JanQ1Wed
92026-01-0820261JanQ1Thu

The first eight rows of the Calendar table (2026-01-01 is a Thursday).

WEEKDAY ( date, 2 ) numbers Monday as 1 and Sunday as 7, which suits European week conventions. FORMAT returns text, so Month and Weekday are labels; MonthNo, YearMonth and WeekdayNo are their numeric sort keys. Note the single quotes in 'Calendar'[Date]: they are optional for simple table names but harmless, and required when a name contains spaces or clashes with a reserved word.

Sorting months correctly

Put the Month column on rows and Excel sorts the text alphabetically: Feb 2,805, Jan 2,587, Mar 1,248. Fix it once in the model and every PivotTable inherits the correct order:

  1. In the Power Pivot window, select the Month column in Data View.
  2. Choose Home › Sort and Filter › Sort by Column › Sort by Column….
  3. Sort column: Month; By column: MonthNo. Click OK.
  4. Repeat for Weekday (by WeekdayNo) and Month Year (by YearMonth).

Each label must map to exactly one sort value. Sorting Month by MonthNo works, because every Jan row has MonthNo 1. Sorting Month by YearMonth fails, because Jan would map to both 202501 and 202601, and Power Pivot reports an error. That is why the Month Year label, which is different in every year, is the one sorted by YearMonth.

Relating and marking the table

  1. In Diagram View, drag Sales[Date] onto 'Calendar'[Date]. The Calendar is the one side, Sales the many side.
  2. Select the Calendar table and choose Design › Mark as Date Table (in some versions Design › Date Table › Mark as Date Table). Pick the Date column and click OK.
  3. Hide Sales[Date] from client tools so that report builders use the calendar's columns instead.
Watch out. If Sales[Date] contains times (for example 2026-03-10 14:32), it will not match any Calendar row, because the Calendar dates are at midnight. Remove the time part in Power Query before loading, or the relationship will silently drop those sales from every date-filtered report.

What the calendar gives you

With the Calendar related, 'Calendar'[Month] on rows shows every month, and you can write measures that use the calendar itself. For example, average revenue per calendar day:

DAX
Revenue := SUM ( Sales[Amount] )
Days := COUNTROWS ( 'Calendar' )
Revenue per Day := DIVIDE ( [Revenue], [Days] )
Days counts calendar days, including days without sales.
ABCD
1MonthRevenueDaysRevenue per Day
2Jan25873183.45
3Feb280528100.18
4Mar12483140.26
5Grand Total66409073.78

'Calendar'[Month] on rows (sorted by MonthNo), Year slicer = 2026, filtered to Jan–Mar.

January had 2,587 of sales over 31 days, which is 83.45 per day. Counting days from Sales instead of the calendar would only count days with orders, which answers a different question. Weekday analysis works the same way:

ABC
1WeekdayRevenueOrders
2Mon38754
3Tue21354
4Wed6302
5Grand Total664010

'Calendar'[Weekday] on rows (sorted by WeekdayNo). Only weekdays with sales appear.

Tip. Add columns you will actually report on, not every possible one. Common extras are a fiscal year (= YEAR ( 'Calendar'[Date] ) + IF ( MONTH ( 'Calendar'[Date] ) >= 7, 1, 0 ) for a year starting in July), an ISO week number and a flag for public holidays loaded from a small table.

Check yourself

1. Which is NOT a requirement for a calendar table?

2. Why are months listed as Feb, Jan, Mar?

3. Can you create a calendar with CALENDARAUTO in Excel Power Pivot?

4. Which WEEKDAY return type numbers Monday as 1?

5. Sales[Date] contains times. What happens with the relationship to Calendar[Date]?