24. Power Pivot and the Data Model
24.5 A Date Table (Calendar)
Give the model a reliable date for every day in scope
Meera reviews two months of fictional retail orders. The fact data includes dates on the days a purchase was recorded, and a report built from the string labels Nov and Oct may sort November before October. A day with no fact row disappears from that raw source. A date dimension, commonly called Calendar, gives the model one approved record for every relevant calendar day. It supplies labels and sorting keys that remain useful even when orders arrive on only a few dates.
The Calendar is like the timetable for the report. Orders are the actual observations that happened. The timetable defines which dates can be selected. It does not create sales on those dates or prove that a source system collected every purchase. Give it a consistent sequence, a unique date key and useful columns such as year and month. Then connect that date key to the actual sales date value and test whether your report follows it.
- Build one date row for each actual date in the approved interval. Keep dates unique, nonblank and without gaps.
- Use compatible date values. A timestamp at noon can display the same day as midnight without matching the same model key.
- Keep period labels and order separate. Use a year-aware period label and chronological sort key where more than one year is possible.
Define the two-month lesson scope before extending it
Use the original 12-order model from 24.1. It has six orders worth ₹1005 in October 2026 and six worth ₹1310 in November 2026. For the simple monthly grouping test, preserve the original Calendar fixture from October 1 through November 30 inclusive. October has 31 days and November has 30, giving 61 date rows. This is an intentionally bounded practice table. For classic DAX time intelligence, Microsoft’s Excel guidance calls for a date row for every day of each relevant year. Extend to the full year and any approved comparison years before the following time-intelligence lesson.
January to December 2026 has 365 calendar days. That full-year Calendar is distinct from the 61-day exercise. Adding rows for January, September and December supplies model filter values. It does not add corresponding order facts. The written coverage must distinguish known empty days from days for which you have no accepted source. Use the full-year dates to identify missing periods and support comparisons, and state which source figures are actually available.
Build the date sequence in a worksheet
Create a worksheet for the date dimension. In A1 put Date. In A2 use the DATE function with numeric year, month and day. This avoids guessing which display format the current Excel locale uses for text such as 01/10/2026. In A3 add one day to the preceding date. Fill A3 down to A62 for the 61-date practice fixture. Inspect that A62 is November 30 and that each date is one day after the prior row.
A2: =DATE(2026,10,1)
A3: =A2+1
Check: =DATE(2026,11,30)-DATE(2026,10,1)+1
In the actual worksheet enter only the formulas starting with the equals symbol, with the labels above showing where they belong. For the full-year extension, use January 1 in the first date cell and generate through December 31. With headings in row 1 and 365 successive date values, the final data row is 366. Plan the year boundary explicitly and check whether future fact dates are in the approved calendar. A date series made from the exact listed fact dates would omit thousands of legitimate comparison days in a longer dataset.
Add fields you can use to group and sort
Use B1 Year, C1 Month Number, D1 Month, E1 Year Month and F1 Year Month Key. In the first data row enter the following formulas and fill down to match the last date. These are worksheet formulas. The calculated Month text depends on the user's formatting language, so Oct and Nov are the English examples. The numerical period index is consistent with the displayed year and month.
B2: =YEAR(A2)
C2: =MONTH(A2)
D2: =TEXT(A2,"mmm")
E2: =TEXT(A2,"mmm yyyy")
F2: =100*YEAR(A2)+MONTH(A2)
| Date | Year | Month Number | Month label | Year Month Key |
|---|---|---|---|---|
| 2026-10-01 | 2026 | 10 | Oct | 202610 |
| 2026-10-02 | 2026 | 10 | Oct | 202610 |
| 2026-10-03 | 2026 | 10 | Oct | 202610 |
| 2026-11-01 | 2026 | 11 | Nov | 202611 |
| 2026-11-30 | 2026 | 11 | Nov | 202611 |
If you prefer short DAX calculated columns after loading dates, a Month Number column can use =MONTH([Date]) and a Month column can use =FORMAT([Date],"mmm") in Power Pivot. These return a value for every Calendar row. The equivalent worksheet formulas above already supply the labels; choose one place where their definitions are maintained. Keep the date key typed as a date even when a formatted Month is convenient for the report.
Convert the final source rectangle into an Excel Table named Calendar and add it to the workbook Data Model. Verify the loaded Calendar occupies the intended range and its Date column has the correct underlying type. Some supported Power Pivot builds offer other calendar creation commands. The explicit worksheet source in this lesson establishes exactly why the first and last dates were included. If using any generated option, verify its actual boundaries, column types and coverage against the same acceptance checks before relying on it.
Mark Calendar and connect it to the fact date
In supported Excel for Windows with Power Pivot, open Manage and choose the Calendar model table. Use Design Mark as Date Table or the Date Table Settings control where offered. Select Calendar Date as the unique nonblank column. This records which column supplies dates for date-related functionality. It does not automatically create matching sales dates, fix a missing date or check the business reporting population. Inspect the calendar and build the relationship separately.
- Check that Calendar Date is a date value, has no blanks or repeated days, and covers the approved interval.
- Check that Orders Date represents the same business date and compatible type. Preserve original raw timestamps if preparing a day-level key.
- Create the one-to-many relationship in Diagram View or the supported relationship dialog. Orders Date is the many-side field, Calendar Date the unique related key.
- Check the relationship is active for the intended sales-date role. Use the Calendar fields when placing dates in report rows or slicers.
- Confirm the model PivotTable gives the two exact month totals and a clear coverage check.
An order can record a date and a time. A Calendar row for October 3 can store midnight while a source fact timestamp stores October 3 at 14:30. Formatting both as dates does not necessarily remove the time value. If your report is deliberately at the business-day grain, derive the approved calendar date in the source preparation. With Power Query choose a date value from a properly typed timestamp using the appropriate local-day policy before relating fields. If an event crosses time zones, determine which reporting timezone the date represents. Preserve the original timestamp separately if it is needed for auditing.
For a controlled workbook test, use the original O-101 amount of ₹128 with a new separate datetime field holding October 3 at 14:30. Keep the approved relationship based on the day. If you incorrectly use the full timestamp as a relationship key, a date-only Calendar row cannot match that instant unless they share the same underlying value. An unmatched fact could still be included in the raw sales total, while the named October slice would lose ₹128. The corrected day key restores that record to the intended calendar date.
Sort labels and inspect empty periods correctly
Use one sorting value for each displayed label
A textual A-to-Z sort can put Nov before Oct. With the Calendar model table, select Month and use the Power Pivot Sort by Column control to sort Month by Month Number where your version exposes it. Ensure all Oct labels map to 10 and all Nov labels map to 11. Recheck the PivotTable’s sorting settings too, especially when a custom or manually selected order competes with the model metadata. The expected English display is Oct followed by Nov.
For a multi-year report, Month alone deliberately groups labels such as Nov together across years unless you also use Year. A Year Month label such as Nov 2026 is distinct from Nov 2027. Set it to sort by Year Month Key when available, or use a date-valued Month Start formatted for display. If you try to sort the bare month label Nov by a key that contains the year, the same label could map to 202611, 202711 and more. Give the base month and specific period separate sort keys. The display label should have one associated sort value at its chosen level of detail.
| Period | Calendar dates | Orders | Amount | Distinct customers |
|---|---|---|---|---|
| Oct 2026 | 31 | 6 | 1005 | 5 |
| Nov 2026 | 30 | 6 | 1310 | 5 |
| Both months | 61 | 12 | 2315 | 6 |
October and November each have five unique customer IDs in the visible approved orders. Four customer IDs appear in both months. The combined distinct count is therefore six. The same customer can place orders in more than one month. Do not add the two displayed counts to get ten real people across the total. Use the model's distinct count over the chosen combined scope and verify the accepted CustomerID values. The printed counts apply to the original fixture with valid nonblank IDs.
Decide when to show months without facts
If you extend Calendar through December, the December dates exist even though this fixture has no December orders. The model can now support a December selection. A given PivotTable may omit empty items, show an empty cell, or display a configured value. Microsoft documents Show items with no data options for eligible OLAP PivotTables, with behavior depending on its source and arrangement. Decide whether the report should show a missing-data indication or a verified zero. A Calendar value alone does not force the visual to show all months or certify zero sales.
Check a date from source through the report
Generate each date
Start October 1 and finish November 30 for the 61-day practice check. Include the days without order records.
Verify one correct key
Calendar has one October 3. The approved O-101 date matches it at day level.
Apply a Calendar filter
Select Oct and trace its six fact rows. Verify they total ₹1005.
Switch the period
Nov selects six separate rows worth ₹1310. Clearing the filter gives ₹2315.
Run two date coverage and reporting tests
Lab 1. Create, mark and sort the original date table
- Build the original worksheet Calendar with the 61 dates and add the approved month fields. Verify the last date and sorted interval.
- Load the Calendar into the practice model, check dates and define its unique date column. Keep the already approved Stores and Products relationships.
- Connect Calendar Date to Orders Date. Use the Calendar's Year and Month fields to group sales.
- Check Oct ₹1005, Nov ₹1310 and total ₹2315. Verify all twelve amounts are represented.
- Add a distinct count of known CustomerID values and verify 5, 5 and 6. Make sure the source identifiers are the approved ones in the original file.
Lab 2. Test a missing calendar date and correct the horizon
- Work on a separate copy of the approved model. Remove October 11 from the source calendar deliberately, leaving the Orders dates and money unchanged. If the model rejects that invalid mark or refresh, record the visible error and use the manual comparison.
- Check why the date source now has 60 records instead of 61. The approved O-103 order with ₹195 cannot match a calendar row for October 11. Other approved dates still exist.
- Without that row, the named October amount can fall to ₹810 while the unrestricted raw sales remain ₹2315. Restore the missing day and recheck coverage.
- In another copy extend the Calendar for all of 2026. Verify 365 dates and distinct month labels, including dates with no matching December facts in the toy source.
- Retain the full-year ready version for the classic time-intelligence exercise. Keep the 61-day version as evidence of the original calendar construction practice.
Remember that the model may fail early for an invalid date table, or a grouping may expose the issue after the data loads. Record the observed first failure instead of assuming that every client returns identical screen results. The invariant is that the subset of fact rows matching the retained October keys loses exactly the ₹195 record when October 11 disappears. Restore a verified one-row-per-day source before checking any time comparison.
Prove that the date table contains the required days
Test start, end, uniqueness and continuity
In the worksheet Calendar table, first check that the earliest and latest dates are the approved endpoints. Then check the number of date rows and the number of numeric Excel date values. On the clean 61-day source both are 61. A date-like text cell or blank can reduce the numeric count while the number of positions stays constant. These controls prove different things. The accepted Date column should contain real dates. Verify the column as a date again in the loaded model rather than relying on the worksheet format.
=MIN(Calendar[Date])
=MAX(Calendar[Date])
=ROWS(Calendar[Date])
=COUNT(Calendar[Date])
=MAX(Calendar[Date])-MIN(Calendar[Date])+1
Keep these formulas outside the Table itself and format the first two as dates. Entering a date format on the other three would obscure their purpose as counts. Check the oldest source day is October 1 and the last is November 30. The inclusive span between those boundaries is 61. A row count equal to that result is helpful evidence, but it can still conceal an omitted date if another date is repeated. Each entry should appear once, with no blank or fractional day when the relationship uses a date-only key.
On a copy, hold the earliest and latest values constant but replace October 11 with another copy of October 12. The Table still has 61 numeric dates and both endpoints match. There are now only 60 unique dates. October 11 is absent. A manual verification can sort the dates and compare each date with its previous row. With an omitted date the difference can jump by two, then fall to zero for the duplicate. Inspect both failure cases before restoring the original. A set of controls can detect a problem the raw row count would miss.
For the practiced sorted sequence a helper next to the data can compare =A3-A2 on each consecutive pair, after ensuring the Date entries are valid dates and sort ascending. Every value from the pair of first days through the last should be one. A duplicate results in zero, and a missing day creates a larger difference. If you choose to use the smaller Calendar worksheet as a source, index its last formula and all helper checks consistently. More automated preparation can compare the accepted dates with a freshly generated sequence.
Generate a fully typed date sequence from approved bounds
The worksheet sequence is enough to complete the exercise. For a separate query-based version, use a blank Power Query in an authoring client with a model load route. Paste the example below into the Advanced Editor in a practice copy. It uses two fixed sample dates and an inclusive day count. It generates one actual date for each day, rather than relying on finding dates in Orders. This code is Power Query M. It belongs in a query, while the DAX functions earlier are entered in model calculations.
let
FirstDate = #date(2026, 10, 1),
LastDate = #date(2026, 11, 30),
DateCount = Duration.Days(LastDate - FirstDate) + 1,
Dates = List.Dates(FirstDate, DateCount, #duration(1, 0, 0, 0)),
CalendarDates = Table.FromColumns({Dates}, type table [Date = date])
in
CalendarDates
Load the output by the Data Model route described earlier if this copy needs a related model table. Keep one approved Calendar source per date role in the core practice model. The query above yields the same 61 dates as the worksheet. Change both boundaries to January 1 and December 31 when you need the full 2026 table. Review the actual output boundaries and the 365-date count after doing so. Add the year and month attributes using query steps, calculated columns or the prepared worksheet route. Keep the chosen definitions together so a new date cannot silently receive inconsistent labels.
If you later want a 2027 report, a source owner should decide whether the dates include approved forecast periods, only the current reporting year or previous comparison years too. A date table can extend ahead of the last approved fact so reports can describe future periods. That is intentional when you clearly distinguish forecasts, source blanks and actual sales. Never treat an approved Calendar range as evidence that an upstream file actually finished collecting observations for December.
Check the fact side against the loaded dates
A complete Calendar can still fail to match the facts. Inspect whether Orders Date is really the date on which the order was placed. A source can also have scheduled delivery and completed delivery timestamps, depending on what is being measured. Define the report date role before choosing a column. If a separate store report chooses shipment dates, use an approved suitable relationship or measure design. Sharing the same year-month label cannot resolve a difference in what the dates mean.
For the typed sample data, there are twelve original fact dates. Verify that every fact row finds exactly one current Calendar Date key. You can use a worksheet COUNTIF with the known Date cell, or a query exception audit on the intended normalized date fields. A clean result expects one approved date lookup for each row. A missing date can hide one fact from a named month, while the fact remains in an unfiltered total. Date uniqueness checks and fact-date coverage checks therefore detect different problems.
Some source columns already have true date values that work as day keys. Others are DateTime or text. In the October 3 timestamp exercise use the intended report day after computing it with the agreed time zone. If you simply change the display format of 14:30 to hide the time, the value may still fail to match. A system receiving times from several regions must first decide which region’s day governs the calculation. A single order near midnight can otherwise move between days or across the October-November boundary. Preserve both values if the business needs clock-time and day-level analysis.
Test labels across a year boundary
Draw three sample date rows on paper: November 1, 2026; December 1, 2026; and January 1, 2027. The month numbers are 11, 12 and 1. Sorting by Month Number alone would put January first, which could work for a seasonal comparison that combines all years in one repeating cycle. A chronological timeline should show November 2026, December 2026, and January 2027 in that order. Their year-month keys are 202611, 202612 and 202701. Use a year-aware label and ordering key in the workbook.
| Period | Month Number | Year Month Key | Chronological position in this test |
|---|---|---|---|
| Nov 2026 | 11 | 202611 | 1 |
| Dec 2026 | 12 | 202612 | 2 |
| Jan 2027 | 1 | 202701 | 3 |
When using the same label in several markets with different display languages, the text can change but the actual date value remains the intended reporting key. A worksheet formatted with a French or Marathi month name can still use the correct Month Number. For a model that reports a company's year starting in April, the calendar year and fiscal year labels need separate definitions. October belongs to the fourth calendar quarter and the third quarter of an April-start year. State the authorized period scheme in the workbook. The current two-month example uses standard calendar months.
Keep reporting coverage separate from calendar coverage
Imagine a source owner approved complete records for October and November as part of an exercise. If a newly requested day has zero records and you know the source population is complete, the business may choose to display zero for that selected day. If the source file stopped arriving, the same model has no matching records yet and the correct response may be an incomplete information label. Both are possible with the same date table. The absence of December facts here simply states what is in the approved fixture. It does not establish what amount a real business earned that month.
Consider a dated approval grid with Date Period, Extract received, Count checked and Approved. Add an entry for October and November with six confirmed teaching orders each and aggregate checks. December can exist as a row in Calendar without a corresponding approved extract. A status beside the analysis can explain the provisional period. This separation helps a learner understand why a PivotTable view can have all calendar labels and still need an explicit completeness control.
For a batch loaded only through November 15, a report labeled November total could combine valid posted numbers and missing later dates without making that clear. Independent input dates or cutoff approval determine what the result represents. Establish whether you compare equal elapsed windows or completed periods. Even a valid DAX measure cannot determine which billing records should have arrived. In the next time-intelligence lesson, check several date comparators against precisely selected intervals.
Build an optional fiscal label with a documented start month
Some companies organize budgets into a year starting April 1. Their fiscal year can be named by its starting or ending calendar year. For this optional example choose the ending-year label. April 2026 through March 2027 is fiscal year 2027. October 2026 is its seventh month and third quarter. The same October is month ten and quarter four of calendar year 2026. Keep both labels available when two audiences need different period definitions. Neither replaces the actual Calendar Date key.
In a separate practice Calendar worksheet, calculate these three fields from the first date cell A2. MOD wraps the month offset into values zero through eleven. Adding one makes April the first fiscal month. ROUNDUP groups the twelve fiscal months into quarters. The final expression adds one to the calendar year for observations in April through December and leaves January through March in their ordinary calendar year.
=MOD(MONTH(A2)-4,12)+1
=ROUNDUP((MOD(MONTH(A2)-4,12)+1)/3,0)
=YEAR(A2)+IF(MONTH(A2)>=4,1,0)
Verify October 2026 gives fiscal month seven, quarter three and ending year 2027. Verify March 2027 gives fiscal month twelve, quarter four and the same ending year. April 2027 begins fiscal month one and quarter one of year 2028. Use an approved year-and-quarter label and a consistent numeric sort key when a reader needs a range longer than one fiscal year. A different fiscal calendar, such as different week-based retail periods, requires its own accepted date mapping. Avoid copying April-based rules onto an organization with another calendar.
Inspect a full date axis while only part of its source is loaded
On a separate input copy, imagine the November extract is approved only through November 15 in this practice. The four known orders up to that day are O-107, O-108, O-109 and O-110. They total ₹910. The Calendar can still contain every day through November 30. Selecting its November label would return the available ₹910 in the incomplete copy. When the remaining two accepted November orders arrive, the amount increases to ₹1310. The date dimension’s November count remains 30 in both models. An unchanged Calendar is consistent with a changed fact population.
Put the two as-of dates beside the two report values. If the approved extract ends on November 15, its result describes that accepted cutoff even though the Calendar contains later dates. A missing-data notice or a scoped date filter can make this visible to readers. If they want to compare two full months, wait for approved November coverage or choose an equivalent elapsed-period comparison. Do not change the real Calendar to hide future dates simply because no facts have arrived yet. Correct the report scope and completeness statement instead.
To check that missing periods are genuinely recorded as missing, distinguish a date outside the Calendar from an included date without a matching fact. October 1 is included in both versions of this exercise, while the source has no fact for that day. An order on December 1 would be outside the 61-day Calendar altogether, but can match the full-year version when its date and load are approved. These situations can look the same in a blank display cell. The audit of loaded date keys identifies which situation you have.
Save one model that gives reliable chronological evidence
After constructing the table, save a simple report with Calendar Year and Month in Rows and the sales result in Values. Record which column you set as the date key and how month order was assigned. Use one date-based filtered result such as October 3 with ₹128 as a precise control. A month total can pass even after two dates swap within the same period. A day-level check can detect where one approved fact moved.
When a new analyst inherits the Calendar, give them the approved sequence boundaries, the period and fiscal rules and the way to check for matching fact keys. Wider history may require adding whole comparison years, observing leap days and confirming that the oldest fact remains within scope. If both 2025 and 2026 are included in a full-year calendar, you expect 730 date records. A calendar covering 2028 must also include its February 29 if that full year is in scope. For next year's handoff, compare the intended dates to a generated reference sequence rather than trusting a hardcoded row count.
Keep the destination report separate from the source approval notes. Extend the worksheet or query horizon only after stating which new years should appear. Then reload and verify the same old reviewed numbers and any officially approved new facts. This leaves a clear record of what changed in Calendar and what changed in Orders. A student should be able to explain why a report with valid Oct and Nov money totals can still need a better chronological or coverage check.
Check one date at the reporting boundary
For a separate example, imagine a ₹50 order recorded at 20:30 UTC on October 31. The same instant is 02:00 on November 1 in India Standard Time. An operational report using Indian business dates assigns it to November. A report defined in UTC assigns it to October. Both are descriptions of the same order. The policy has to decide which day is correct before you strip off the time. If you first truncate the UTC timestamp to October 31, changing its later display format cannot recover the intended local November date.
Try the comparison on a test list with only that one synthetic event. Record both dates and the one approved timestamp. Verify that the chosen model day matches the relevant Calendar row and that the report’s overall ₹50 stays the same. Months are grouping labels based on the selected day. Before putting a date from a connector or another team's export into a relationship, ask which time zone and phase of the event that date represents. The original twelve-order workbook already gives day-level values and requires no timezone conversion.
End the date audit with two independent records: the checked list of allowed Calendar dates, and the count and amount of sales whose field actually matched those dates. The first establishes the reporting dimension. The second confirms the fact coverage within it. This distinction remains important when the source contains dates with several purchases and many days with no fact at all.
Record one exact day and one month total so the reviewer can distinguish incorrect date identity from an incorrect aggregate.
Explain the date dimension, the fact date and the period results
Quiz
Why does the initial Calendar have 61 dates?
It includes both endpoints. October has 31 days and November 30. The source Orders list has only twelve approved records, so it cannot supply all those dates by itself.
What is the difference between Month Number and Year Month Key?
Month Number sorts months within a year or season. Year Month Key includes the year so separate Novembers can be ordered and grouped independently.
Does a missing December order prove zero business activity?
No accepted December facts are available in this fixture. The calendar supplies a selectable time period. Independent confirmation of approved source coverage would be needed to conclude zero activity.
Where should the fact date and model date be matched?
Connect the approved Orders day-level date field to the unique Calendar Date and verify the active relationship and matching value types.
Why is the overall distinct customer count six?
There are five known customers in each month and four appear in both. The combined model calculation counts each known CustomerID once.
Interview questions and answers
What does a date table provide that Orders may not?
Every approved date, day-level identity and consistent period descriptors independent of event presence on particular days.
How do you verify that a Calendar has no gaps?
Check expected first and last dates, ensure every row has one valid date, and verify consecutive dates or a comparison with an independently generated reference list.
How would you debug a missing amount after applying Calendar Month?
Compare the fact date and calendar date as values, including any time part, check the approved date range and active relationship, and verify matching orders.
Which Calendar would you use for classic Excel time intelligence?
Use unique dates for every day in the relevant full years, including comparison horizons. Mark the correct model table and relate actual fact event dates.
What happens if you use Month labels alone across many years?
Matching labels can represent several different years. Use Year plus Month or a year-aware period label, with an appropriate chronological key.
Revision cards
- One date per row. Check actual unique consecutive date values.
- Practice versus comparison. Start with 61 days for the two-month exercise and use full years for classic time tasks.
- Use the matching day. Remove timestamps from the business-day key where required.
- Mark and relate. Specify the unique Calendar date and confirm the active path to facts.
- Sort the period. Bare month and year-month labels need different keys.
- Label ≠ observation. A date in Calendar can exist without a matching accepted fact.
See the original Calendar illustration, visit the Excel Practice Task Hub, or continue to loading approved monthly files.
Microsoft references
- Mark as Date Table in Power Pivot
- Full-year date coverage for Excel time intelligence
- Excel model dates and columns
- Relationship types and date keys
- PivotTable empty items and display choices
- Underlying Date and DateTime behavior
- Distinct count across groups and grand totals
- Generate each requested date with List.Dates
- Build the typed table from a date list
- Converting supported date values in Power Query