Date table in Power BI: build it in DAX or Power Query

Why every Power BI model needs a date table, the rules for one (unique, no blanks, contiguous dates), building it with CALENDAR, ADDCOLUMNS or Power Query, fiscal years, sort columns, marking it as a date table, turning off auto date/time, and relationships.

Short answer: a date table has one row per day for whole years, with columns for year, quarter, month, week and fiscal periods, and a relationship to every date in your fact tables. Classic time intelligence (DATESYTD, SAMEPERIODLASTYEAR) needs it: Microsoft lists its rules as unique values, no blanks, and contiguous dates from start to end. Build it with DAX (CALENDAR plus ADDCOLUMNS) or Power Query, mark it as a date table, sort month names by month number, and turn off auto date/time.

Without a date table, Power BI creates a hidden one per date column (auto date/time): the model grows, fiscal years are impossible, and order date and ship date cannot share one slicer.

What does a good date table contain?

ColumnExampleUsed for
Date2026-10-29the key for relationships
Year2026slicers, axes
QuarterQ4axes
Year Quarter2026 Q4axes across years
Month Number10sorting month names
Month NameOctoberaxes, sorted by Month Number
Year Month2026-10continuous month axis
Week (ISO)44weekly reports
WeekdayThursdaypatterns by day, sorted by weekday number
Fiscal YearFY2027fiscal reports (year starting 1 July)
Is Working DayTRUEworking-day counts
Columns of a typical date table

How do you build it in DAX?

Date =
VAR FirstYear = YEAR ( MIN ( Sales[Order Date] ) )
VAR LastYear = YEAR ( MAX ( Sales[Order Date] ) )
RETURN
    ADDCOLUMNS (
        CALENDAR ( DATE ( FirstYear, 1, 1 ), DATE ( LastYear, 12, 31 ) ),
        "Year", YEAR ( [Date] ),
        "Quarter", "Q" & QUARTER ( [Date] ),
        "Year Quarter", YEAR ( [Date] ) & " Q" & QUARTER ( [Date] ),
        "Month Number", MONTH ( [Date] ),
        "Month Name", FORMAT ( [Date], "MMMM" ),
        "Year Month", FORMAT ( [Date], "YYYY-MM" ),
        "ISO Week", WEEKNUM ( [Date], 21 ),
        "Weekday Number", WEEKDAY ( [Date], 2 ),
        "Weekday", FORMAT ( [Date], "dddd" ),
        "Fiscal Year", "FY" & ( YEAR ( [Date] ) + IF ( MONTH ( [Date] ) >= 7, 1 ) ),
        "Is Working Day", WEEKDAY ( [Date], 2 ) <= 5
    )

Whole years matter: DATESYTD and SAMEPERIODLASTYEAR work on complete years. WEEKNUM ( date, 21 ) returns ISO 8601 weeks (Monday start, week 1 contains the first Thursday). WEEKDAY ( date, 2 ) numbers Monday as 1.

CALENDARAUTO ( ) builds whole years covering all dates in the model, but it also picks up birth dates and far-future dates, so a range from the fact table is safer.

How do you build it in Power Query?

Power Query is better when the table is shared or needs holidays from a source. Microsoft's example starts with:

let
    StartDate = #date(2022, 1, 1),
    EndDate = #date(2026, 12, 31),
    NumberOfDays = Duration.Days(EndDate - StartDate) + 1,
    DateList = List.Dates(StartDate, NumberOfDays, #duration(1,0,0,0)),
    DateTable = Table.FromList(DateList, Splitter.SplitByNothing(), {"Date"}),
    AddYear = Table.AddColumn(DateTable, "Year", each Date.Year([Date]), Int64.Type)
in
    AddYear

Add the other columns with Table.AddColumn in the same way, then set the Date column's type to Date.

What do you set in the model?

  1. Mark as date table: select the table, Table tools, Mark as date table, choose the Date column. Power BI checks the rules.
  2. Sort by column: Month Name by Month Number, Weekday by Weekday Number, Year Month is already sortable.
  3. Relationships: Date[Date] one-to-many to each fact date column; one active (order date), others inactive for USERELATIONSHIP.
  4. Turn off auto date/time: File, Options, Current file, Data load, Auto date/time, and for new files under Global.
  5. Hide the fact tables' date columns, so everyone slices by the Date table.

What goes wrong?

  • Dates with times. A Date/Time column with times does not match the date table's midnight values; convert to Date.
  • Gaps. A date table built from distinct order dates has holes, and classic time intelligence throws an error on missing dates.
  • Partial years. Starting on the first sale date breaks year-to-date and last-year comparisons at the edges.
  • Month names sorted alphabetically. April first; set Sort by column.
  • Auto date/time left on. Hidden tables for every date column grow the model.

Where can you check this?

Where do you start?

Build the DAX date table above, mark it, connect it, and turn off auto date/time. Then YTD, QTD and MTD and year over year work with one line each.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.