Date table in Power BI: create and mark it with DAX
Last updated · SANTOSPANHOL, S.L.
A date table in Power BI is a table with one row per day, with no gaps, covering the whole period of your data and marked as a date table so DAX time-intelligence functions (year-to-date, same period last year) work.
Create it with DAX
Under Modeling → New table, paste this formula (adjust F_Sales[Date] to your column):
D_Date =
ADDCOLUMNS(
CALENDAR(
DATE(YEAR(MIN(F_Sales[Date])), 1, 1),
DATE(YEAR(MAX(F_Sales[Date])), 12, 31)
),
"Year", YEAR([Date]),
"Month no", MONTH([Date]),
"Month", FORMAT([Date], "mmm"),
"Quarter", "Q" & QUARTER([Date])
)It starts on 1 January of the first year and ends on 31 December of the last, with no gaps.
Mark it and relate it
- Select the table → Table tools → Mark as date table → pick the
Datecolumn. - Relate
D_Date[Date]toF_Sales[Date], one-to-many, single direction. - Sort
MonthbyMonth no(Sort by column) so January comes before April. - Hide the date column in the facts: always filter from
D_Date.
What it unlocks
With the table marked, TOTALYTD, SAMEPERIODLASTYEAR and DATEADD work. The formulas are in the sales DAX measures.
Common slips
- Datetimes in the facts: strip the time so they match the day.
- A date table that does not cover the whole range: data outside it has no year.
- Auto date/time switched on: it creates hidden tables for every date column; switch it off in Options.
Excel to Power BI creates the date table, marks it and relates it for you. Try it with your Excel.
FAQ
Why do I need a date table if I already have a date column?
Because time-intelligence functions require consecutive days with no gaps. A date column in the facts only holds the days with sales.
What range should the date table cover?
From 1 January of the first date's year to 31 December of the last date's year.
Can I use CALENDARAUTO?
Yes. CALENDARAUTO() finds the range by itself; the MIN and MAX formula gives you explicit control over it.
Related guides
- Star schema in Power BI: what it is and how to build one
- DAX measures for sales in Power BI
- How to go from Excel to Power BI in 5 minutes
Your Excel, turned into a Power BI report. Free preview; download for 49,99 EUR (VAT included).