How to Create a Date Table in Power BI
Quick answer
To create a date table in Power BI:
- Go to Modeling and click New table.
- Type
Date = CALENDAR(DATE(2024,1,1), DATE(2026,12,31))and press Enter. - Add columns for Year, Month and Month Number.
- Right-click the table and choose Mark as date table. Pick the Date column.
- In Model view, drag
Date[Date]ontoOrders[OrderDate]to make the relationship.
Real example first: Swiggy orders by month
Suppose we are at Swiggy. We have an Orders table with one row per order. Each row has an OrderDate and an Amount.
| OrderID | OrderDate | City | Amount |
|---|---|---|---|
| 1001 | 05-Jan-2026 | Pune | 450 |
| 1002 | 05-Jan-2026 | Mumbai | 300 |
| 1003 | 14-Feb-2026 | Pune | 620 |
| 1004 | 02-Mar-2026 | Mumbai | 200 |
The manager asks: "Show me sales for every month, and this year's total so far." There is a problem. No order happened on many days. If we use OrderDate directly, those days and months simply do not exist. Time functions like TOTALYTD also need a full list of dates with no gaps.
So we build a separate table that has every single date, one row per day. This is called a date table (some people call it a calendar table).
What is a date table in Power BI?
A date table is a table with one row for each day, from the first date in your data to the last date. It has no gaps. Other columns describe each day: year, month name, month number, quarter, weekday.
Why do we need it?
- Every month shows in a chart, even a month with zero sales.
- Time intelligence functions such as
TOTALYTD,SAMEPERIODLASTYEARandDATESMTDwork correctly. - One date table can filter many fact tables (orders, refunds, deliveries) at the same time.
- Months sort in calendar order (Jan, Feb, Mar), not alphabetical order (Apr, Aug, Dec).
Worked example 1 (simplest): CALENDAR with fixed dates
Steps:
- Open Power BI Desktop with the Swiggy
Orderstable loaded. - Click Modeling, then New table.
- Type this formula and press Enter:
Date = CALENDAR ( DATE ( 2026, 1, 1 ), DATE ( 2026, 12, 31 ) )
Output: a new table called Date with one column Date and 365 rows, from 01-Jan-2026 to 31-Dec-2026.
Worked example 2: CALENDARAUTO (Power BI finds the dates)
If you do not want to type dates, use:
Date = CALENDARAUTO ()
What happens:
- Power BI looks at every date column in your model.
- It finds the smallest and largest date.
- It makes full years: from 1 January of the first year to 31 December of the last year.
Output for our Swiggy data (Jan to Mar 2026): 365 rows, 01-Jan-2026 to 31-Dec-2026.
Be careful: if any table has a wrong date like a birth date of 1900, CALENDARAUTO will start from 1900. Fixed dates or the next example are safer.
Worked example 3: date range from the Orders table
Date =
CALENDAR (
DATE ( YEAR ( MIN ( Orders[OrderDate] ) ), 1, 1 ),
DATE ( YEAR ( MAX ( Orders[OrderDate] ) ), 12, 31 )
)
Output: the table always covers full years of your real orders. When new orders arrive next year and you refresh, the table grows by itself.
Worked example 4: add Year, Month and Quarter columns
Select the Date table, click New column, and add each line one by one:
Year = YEAR ( 'Date'[Date] )
Month Number = MONTH ( 'Date'[Date] )
Month = FORMAT ( 'Date'[Date], "MMM" )
Quarter = "Q" & QUARTER ( 'Date'[Date] )
Weekday = FORMAT ( 'Date'[Date], "ddd" )
Output for one row:
| Date | Year | Month Number | Month | Quarter | Weekday |
|---|---|---|---|---|---|
| 14-Feb-2026 | 2026 | 2 | Feb | Q1 | Sat |
Fix month order: click the Month column, choose Sort by column, and pick Month Number. Now Jan comes before Feb, not after Apr.
Worked example 5: the same date table in Power Query
Some teams prefer Power Query, so the table is ready before the data loads. Steps:
- Click Home, then Transform data.
- Click New Source, then Blank Query.
- Open Advanced Editor and paste the code below.
- Rename the query to
Dateand click Close & Apply.
let
Start = #date(2026, 1, 1),
End = #date(2026, 12, 31),
Days = Duration.Days(End - Start) + 1,
List = List.Dates(Start, Days, #duration(1, 0, 0, 0)),
Table = Table.FromList(List, Splitter.SplitByNothing(), {"Date"}),
Typed = Table.TransformColumnTypes(Table, {{"Date", type date}}),
Year = Table.AddColumn(Typed, "Year", each Date.Year([Date]), Int64.Type),
Month = Table.AddColumn(Year, "Month", each Date.ToText([Date], "MMM"), type text)
in
Month
Output: the same 365-row table, with Year and Month columns.
| Way | Where you write it | Best for |
|---|---|---|
| CALENDAR (DAX) | Modeling → New table | Fixed, known date range |
| CALENDARAUTO (DAX) | Modeling → New table | Quick start, clean data |
| Power Query (M) | Transform data → Blank Query | Teams that do all shaping in Power Query |
Mark as date table and create the relationship
Steps:
- In the Fields pane, right-click the
Datetable. - Choose Mark as date table.
- Select the
Datecolumn and click OK. Power BI checks there are no gaps and no repeats. - Open Model view.
- Drag
Date[Date]ontoOrders[OrderDate]. You get a one-to-many relationship (1 on Date, many on Orders).
Now build a visual: put Date[Month] on the axis and Orders[Amount] as the value. Output: Jan 750, Feb 620, Mar 200, and the other months show as empty instead of disappearing.
Use it: sales year to date
Sales YTD = TOTALYTD ( SUM ( Orders[Amount] ), 'Date'[Date] )
Output by month: Jan 750, Feb 1,370, Mar 1,570. Each month adds to the total so far. This works only because the date table has every day.
Common mistakes
- Using
Orders[OrderDate]on the axis instead ofDate[Date]. Then time functions give wrong totals. - Forgetting the relationship. Every month then shows the same grand total.
- OrderDate has a time part (like 05-Jan-2026 14:30). Change its data type to Date so it matches.
- Month names sorted alphabetically. Use Sort by column with Month Number.
Quick quiz: check what you learned
Why do we need a date table?
- It has every day with no gaps
- It makes the file much smaller
- It removes the need for measures
- It changes the order amounts
Show answer
A. Time functions need every day.
Which formula makes a fixed range?
- CALENDAR with two DATE values
- CALENDARAUTO with no inputs
- FORMAT with a MMM pattern
- QUARTER with a date column
Show answer
A. CALENDAR takes a start and end date.
How do you fix month order?
- Sort Month by Month Number
- Rename the Month column
- Delete the Year column
- Mark Orders as date table
Show answer
A. Sort by column fixes the order.
What is the relationship type?
- One Date row to many Orders
- Many Date rows to one Order
- One Date row to one Order
- No relationship is needed
Show answer
A. Each date can have many orders.
Learn it properly
Related guides: Turn off auto date/time · Year to date with TOTALYTD · Month and quarter to date