MSBA-261 · Lesson 3 of 12 · 19 min
Date tables
▶ Video coming soon A video version of this lesson is on the way.
Almost every question the Lumenvale deans asked had a time in it. How many students this fall compared with last fall? Which weeks of the term bring the most late registrations? How does September's bookstore revenue compare with the same month last year? Kwabena knew that a good date table would be the most reused table in the whole model, and the one most likely to cause subtle errors if he got it wrong. The PL-300 study guide asks candidates to create a common date table and to implement role-playing dimensions, and this lesson does both.
Why a separate date table?
Fact tables already contain dates, so why add a table of them? There are three reasons.
- Shared filtering. One Date table related to Registration, Outlet Sales and Program Budget lets one slicer filter all three, which a date column inside each fact table cannot do.
- Attributes for grouping. Readers want to group by fiscal year, term, week of term, month name and weekday. These attributes belong on a dimension, computed once, not recalculated in every visual.
- Time intelligence. DAX functions that compare periods, such as year to date or same period last year, need a contiguous range of dates with no gaps to work correctly.
Power BI has an Auto date/time option that silently creates a hidden date table for every date column in the model. It is convenient in a quick personal report, but in a shared model it is wasteful and limiting: each hidden table adds size, the hidden tables cannot be shared across fact tables, and they know nothing about fiscal years or terms. Microsoft's guidance is to turn Auto date/time off for models that use a proper date table, and Kwabena turned it off in both the current file and the global options so new files would start that way.
What a good date table contains
A date table has one row per day and a column of unique dates with no gaps, covering every date the model needs. Kwabena's covered 1 July 2015, the start of the earliest fiscal year in the student system, to 30 June 2028, a little beyond the last budget year, so that future-dated registrations and budgets would always find their dates.
| Column | Example for 15 October 2026 | Why it exists |
|---|---|---|
| Date | 2026-10-15 | The unique key used for marking the table and for time intelligence |
| DateKey | 20261015 | A whole-number key matching integer keys in the fact tables |
| Year, Quarter, Month Number, Month Name | 2026, Q4, 10, October | Calendar grouping; Month Name sorted by Month Number |
| Fiscal Year, Fiscal Month | FY2027, 4 | Lumenvale's fiscal year starts 1 July |
| Term | Fall 2026 | Academic terms used in every enrollment report |
| Week of Term | 7 | Comparing registrations at the same point in each term |
| Is Weekday | True | Filtering outlet sales to teaching days |
| MonthKey | 202610 | A month-level key for the monthly budget fact table |
Three ways to build a date table
There are three common ways to build the table, and each has a place.
From the source. Many data warehouses already have a date dimension maintained by the data team. If one exists, use it, because every report and system in the organization then agrees on fiscal periods. Lumenvale's student system had a term calendar table but no full date dimension, so Kwabena could use it only for term attributes.
In Power Query. A date table can be generated in Power Query with a list of dates and added columns. This keeps all data preparation in one place and is often preferred when the table must match logic used in dataflows that other models share.
In DAX, as a calculated table. The CALENDAR and CALENDARAUTO functions return a single column of dates, and ADDCOLUMNS adds attributes. Kwabena chose DAX for his first version because it was quick to read and change, then planned to move it into the college's shared dataflow later so other models could reuse it.
Date =
VAR FirstDate = DATE ( 2015, 7, 1 )
VAR LastDate = DATE ( 2028, 6, 30 )
RETURN
ADDCOLUMNS (
CALENDAR ( FirstDate, LastDate ),
"DateKey", YEAR ( [Date] ) * 10000 + MONTH ( [Date] ) * 100 + DAY ( [Date] ),
"Year", YEAR ( [Date] ),
"Month Number", MONTH ( [Date] ),
"Month Name", FORMAT ( [Date], "MMMM" ),
"Fiscal Year", "FY" & ( YEAR ( [Date] ) + IF ( MONTH ( [Date] ) >= 7, 1, 0 ) ),
"Fiscal Month", MOD ( MONTH ( [Date] ) - 7, 12 ) + 1,
"MonthKey", YEAR ( [Date] ) * 100 + MONTH ( [Date] ),
"Is Weekday", WEEKDAY ( [Date], 2 ) <= 5
)CALENDARAUTO scans every date column in the model and returns full years covering them all. It sounds convenient, but a stray birth date from 1902 in a student table, or a placeholder date of 31 December 9999, can make it generate thousands of meaningless years. An explicit range with CALENDAR is safer and easier to explain.
The Term and Week of Term columns came from the student system's term calendar. Kwabena merged it into the date table so that each date carried its term, which then made it trivial to compare enrollment at week 7 of fall 2026 with week 7 of fall 2025.
Marking the table as a date table
After creating the table, Kwabena selected it in the model view and used Mark as date table, choosing the Date column. Marking tells Power BI that this table is the model's calendar. Power BI validates the column: it must be of the date data type, contain unique values, have no blanks and cover whole contiguous ranges. Once marked, time intelligence functions behave correctly even when the relationship to the fact table uses a whole-number key rather than the date column itself, and Power BI stops creating automatic hierarchies for that column.
Marking also matters for readers. A marked date table is the one that features such as Copilot and quick measures recognize as the calendar, and it encourages report authors to use its columns instead of raw fact-table dates.
Microsoft has also introduced calendar-based time intelligence, which lets a model define calendars, such as a fiscal calendar or a 4-4-5 retail calendar, on the date table and have time intelligence functions follow them. Check its current status in Power BI Desktop before relying on it in an exam answer; the classic functions and a marked date table remain the foundation.
Sorting and hierarchies
Month Name sorts alphabetically unless told otherwise, putting April before January. Kwabena set Month Name to sort by column Month Number, and set Term to sort by a hidden Term Sequence column so that Winter 2026, Spring 2026, Summer 2026 and Fall 2026 appeared in academic order.
He then built hierarchies in the Date table: a calendar hierarchy of Year, Quarter, Month and Date, and a fiscal hierarchy of Fiscal Year, Fiscal Month and Date. Hierarchies let readers drill down in visuals, and keeping them in the Date table means every report gets the same drill path.
Role-playing dimensions
Maribeth's request from the whiteboard now had to be solved. An Registration row has two dates: the term start date, which tells which term the registration counts toward, and the registration date, which tells when the student actually registered. Deans wanted both. "Show me fall headcount by program" uses the term. "Show me how many registrations came in during the week before classes started" uses the registration date.
One Date table playing two roles is called a role-playing dimension. Because only one relationship between Date and Registration can be active, there are two standard designs.
Option 1: one table, one inactive relationship. Keep a single Date table. Make the term start relationship active and the registration date relationship inactive. Measures that need the registration role use USERELATIONSHIP. This keeps the model small and keeps one Date slicer for everything, but readers cannot slice by both dates at once, and every registration-date measure must be written specially.
Registrations by Registration Date =
CALCULATE (
[Registrations],
USERELATIONSHIP ( Registration[RegistrationDateKey], 'Date'[DateKey] )
)Option 2: one table per role. Create a second date table, such as Registration Date, either by referencing the same Power Query query or with a calculated table, and relate each copy actively to its own key. Readers can then slice by term date and registration date at the same time, and every measure works with both. The cost is a slightly larger model and two date slicers that must be clearly named so readers know which one they are using.
Kwabena chose option 1 for the enrollment model, because the registration-date questions were few and specific, and option 2 for a separate admissions model, where application date, offer date and acceptance date all needed to be sliced together.
Worked problem
Choosing a role-playing design
The admissions office wants a matrix showing applications by application month on rows and decision month on columns. Should Kwabena use one Date table with inactive relationships or a table per role?
Show solution
- The visual needs both dates at once: application month on rows and decision month on columns.
- With one Date table, only one relationship can be active, so both axes would come from the same date role.
- Create a second date table, such as Decision Date, and relate it actively on the decision date key.
- Name the tables and their columns clearly, for example Application Month and Decision Month, so the matrix is unambiguous.
Answer: Use a table per role, because the visual slices by both dates simultaneously.
Date keys and time zones
Kwabena related the fact tables to Date on the whole-number DateKey rather than on a date-time column. Fact columns that contain a time of day, such as a sales timestamp of 15 October 2026 at 14:32, will not match a date table row of 15 October at midnight, and the unmatched rows fall into the blank row. Converting timestamps to a date, or a date key, in Power Query avoids the problem. Outlet sales timestamps were also stored in UTC, so the Power Query step converted them to local time before taking the date; otherwise late-evening sales would have been counted on the following day.
Testing the date table
A date table is worth testing as carefully as any measure, because every time comparison depends on it. Kwabena wrote four checks into DAX query view and kept them in a saved query tab. The first counted rows and compared the count with the number of days between the first and last date, which proves there are no gaps or duplicates. The second listed the minimum and maximum dates in each fact table and confirmed they fell inside the date table's range, so no fact rows would land in a blank row. The third checked that every date had a Term value and that each term had a sensible number of weeks. The fourth compared the fiscal year label of a few known dates, such as 30 June and 1 July, with the finance office's calendar.
EVALUATE
ROW (
"Rows", COUNTROWS ( 'Date' ),
"Days in range", DATEDIFF ( MIN ( 'Date'[Date] ), MAX ( 'Date'[Date] ), DAY ) + 1,
"Registration from", CALCULATE ( MIN ( Registration[TermStartDate] ), REMOVEFILTERS () ),
"Registration to", CALCULATE ( MAX ( Registration[TermStartDate] ), REMOVEFILTERS () )
)These checks found one real problem. The summer term in 2020 had been shortened during the pandemic, and the term calendar table listed it with a different week numbering. Week of Term comparisons with summer 2020 would have been misleading, so Kwabena added an Is Standard Term flag that report pages could filter on, and noted the exception in the column's description.
One date table, shared by many models
The college ended up with five semantic models that needed the same calendar: enrollment, finance, human resources, facilities and the tutoring model from an earlier course. Rather than five slightly different date tables, Rupert asked Kwabena to move the date logic into a Dataflow Gen2 in the shared Lumenvale Data workspace, so that every model loaded the same table. A fiscal year rule would then be changed once. Shared date dimensions are a governance decision as much as a technical one, and they are a good example of putting logic as far upstream as possible.
Common mistakes
MistakeLeaving Auto date/time on in a shared model with a proper date table.
InsteadTurn it off, use one marked date table, and relate every fact table to it.
MistakeUsing CALENDARAUTO in a model with outlier dates.
InsteadUse CALENDAR with an explicit start and end that covers the facts and budgets.
MistakeRelating a date table to a date-time column that includes times.
InsteadConvert timestamps to dates or date keys, after any time zone conversion, before relating.
MistakeAdding a second active relationship for a second date role.
InsteadUse an inactive relationship with USERELATIONSHIP, or a separate date table for that role.
Summary and key terms
- A shared date table lets one slicer filter every fact table and supplies attributes such as fiscal year and term.
- Turn off Auto date/time in shared models and use a single, explicit date table.
- Date tables can come from the source, Power Query or a DAX calculated table built with CALENDAR and ADDCOLUMNS.
- Mark the table as a date table; the date column must be unique, contiguous and free of blanks.
- Sort text columns such as Month Name by numeric columns, and build calendar and fiscal hierarchies.
- A role-playing dimension is one dimension used for several dates; model it with inactive relationships and USERELATIONSHIP, or with one table per role.
- Relate on date keys after converting timestamps, including time zone conversion, to avoid blank rows.
- Date table
- A dimension with one row per day and attributes for grouping by time.
- Mark as date table
- A setting that identifies the model's calendar table and validates its date column.
- Auto date/time
- An option that creates hidden date tables for each date column; best turned off in shared models.
- CALENDAR
- A DAX function that returns a column of dates between a start and end date.
- Role-playing dimension
- One dimension, such as Date, related to a fact table in several roles.
- Fiscal year
- An organization's financial year, which may start in a month other than January.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Give two requirements for a column used to mark a date table.
Show answer
Any two of: date data type, unique values, no blanks, contiguous dates covering whole periods.
Why can a CALENDARAUTO table become very large?
Show answer
It spans every date in the model, so outliers such as 1902 or 9999 create many unnecessary years.
Which design lets readers slice by two date roles in the same visual?
Show answer
A separate date table for each role, each with an active relationship.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.