Date table

A date table that makes time intelligence work

Year over year, year to date and month to date all fail the same way without a proper date table: blank results, or numbers that look plausible but are wrong. One table of dates, marked correctly and related to the fact table, fixes all of them at once.

Five minutes to set upOne row per dayRequired for YoY / YTD
P
DimDateOne row per date, no gaps
8 min read
Datekey
Year2024
QuarterQ3
MonthSep
MonthNumber9
IsWeekendFALSE
GrainOne row per day
RangeAll data + full year
Relationship1 → many, single
Must doMark as date table
Why it breaks

What happens without one

Blank YoY

SAMEPERIODLASTYEAR needs a column of dates with no gaps. A fact-table date column only contains dates that had sales, so the function has nothing to shift.

Wrong month order

Sorting a text month name alphabetically gives April, August, December. A MonthNumber column plus "Sort by column" fixes the axis.

Missing periods

Months with no sales disappear from the axis instead of showing zero, so trends and averages are misread.

Build it

Five steps, one table

1 · Create the table with DAX

Modeling → New table. Cover every date in the data plus the full current year, so future months exist as empty rows.

DimDate =
ADDCOLUMNS(
    CALENDAR( DATE( 2022, 1, 1 ), DATE( 2026, 12, 31 ) ),
    "Year",        YEAR( [Date] ),
    "Quarter",     "Q" & QUARTER( [Date] ),
    "MonthNumber", MONTH( [Date] ),
    "Month",       FORMAT( [Date], "mmm" ),
    "IsWeekend",   WEEKDAY( [Date], 2 ) > 5
)

Prefer loading it from Power Query if you want fiscal years, holidays or a custom week start — the same idea, built as a list of dates and expanded with columns.

2 · Mark it as a date table

Model view → right-click DimDate → Mark as date table → choose the Date column. Without this flag, time intelligence functions either return blanks or silently use the wrong column.

3 · Relate it to the fact table

Drag DimDate[Date] onto the fact table's date column. The relationship must be one-to-many (date on the one side) and single direction. If your fact table stores a key like 20260915, add that same key to DimDate and relate on it instead.

4 · Sort month names correctly

Select the Month column → Column tools → Sort by column → MonthNumber. Charts then read January to December rather than alphabetically.

5 · Use only the date table's columns in visuals

Hide the fact table's date column. If a visual uses the fact date and a measure uses DimDate, filters split and the numbers disagree with each other.

What it unlocks

Three measures that only work once the table exists

Sales YTD = TOTALYTD( [Total sales], 'DimDate'[Date] )

Sales YoY % =
VAR Current = [Total sales]
VAR Prior = CALCULATE( [Total sales], SAMEPERIODLASTYEAR( 'DimDate'[Date] ) )
RETURN DIVIDE( Current - Prior, Prior )

Sales MTD = TOTALMTD( [Total sales], 'DimDate'[Date] )

Each one assumes a single, continuous, marked date table. Get that right once and every time-based measure in the model inherits it.

Pitfalls

Five things that quietly break a date table

ProblemSymptomFix
Gaps in the datesYTD resets, YoY blank for some monthsBuild with CALENDAR, never from DISTINCT of fact dates
Duplicate datesRelationship becomes many-to-many, totals doubleRemove duplicates; the date column must be unique
Date + time in the keyRelationship fails or filters missStrip the time component, or join on the date part
Table not markedTime intelligence returns blank or wrong valuesMark as date table and point at the Date column
Two date tablesInconsistent results between visualsKeep one date table; model extra roles as separate relationships + inactive ones
FAQ

Common questions about date tables

Can I use Auto date/time instead?

Turn it off. It creates a hidden date table per date column, bloats the model and behaves inconsistently with your own measures. One explicit date table is simpler and smaller.

How far into the future should it go?

To the end of the current year at minimum, plus any forecast horizon you report on. Past dates should start at the earliest date in the data.

Do I need a fiscal calendar?

If the business reports on a non-calendar year, add FiscalYear and FiscalMonth columns to the same table and sort month names by the fiscal order.

Where does the date column in the fact table go?

Keep it as a relationship key and hide it. Every visual and measure should use the date table's columns.

Does this work in DirectQuery?

Yes, but the date table should be imported (a calculated table or a small Power Query table) so the engine can filter it locally.

Next

Now the measures

Six DAX measures

Sales, orders, average order value, year over year, share of total and running total — with the filter context explained.

Read the DAX guide

Star schema in five steps

If the model is still one flat table, start there: the date table is one of its five steps.

Read the star schema guide