Blog

How to create a date table in Power BI in 2 simple steps

A couple of months ago my colleague Franky Leeuwerck wrote an excellent blog post on how to create a complete date table (calendar dimension) in 6 steps in PowerPivot for Excel.

With the introduction of “calculated columns” in Power BI Desktop, things have become even easier. In this blog post I will show you how to create a complete date table is just 2 simple steps.

Step 1 Create the calculated table

Go to the modelling ribbon, where you will now find a new button called “New Table”.

151013b

If you click on this button you can write a DAX expression, similar to how you would have done with the calculated columns and measures before.

The following DAX expression will generate a single column table containing 1 row for every single date between 1 January 2000 and 31 December 2025.

Date =CALENDAR (DATE(2000;1;1); DATE(2025;12;31))

That’s just the start. We will enhance this formula with ADDCOLUMNS()) to add extra calculated columns to the table, such as month, year, day of the week, etc.


Date =
ADDCOLUMNS (
CALENDAR (DATE(2000;1;1); DATE(2025;12;31));
"DateAsInteger"; FORMAT ( [Date]; "YYYYMMDD" );
"Year"; YEAR ( [Date] )
)

151013d

The final formula for the calculated table should look something like this:

Date =
ADDCOLUMNS (
CALENDAR (DATE(2000;1;1); DATE(2025;12;31));
"DateAsInteger"; FORMAT ( [Date]; "YYYYMMDD" );
"Year"; YEAR ( [Date] );
"Monthnumber"; FORMAT ( [Date]; "MM" );
"YearMonthnumber"; FORMAT ( [Date]; "YYYY/MM" );
"YearMonthShort"; FORMAT ( [Date]; "YYYY/mmm" );
"MonthNameShort"; FORMAT ( [Date]; "mmm" );
"MonthNameLong"; FORMAT ( [Date]; "mmmm" );
"DayOfWeekNumber"; WEEKDAY ( [Date] );
"DayOfWeek"; FORMAT ( [Date]; "dddd" );
"DayOfWeekShort"; FORMAT ( [Date]; "ddd" );
"Quarter"; "Q" & FORMAT ( [Date]; "Q" );
"YearQuarter"; FORMAT ( [Date]; "YYYY" ) & "/Q" & FORMAT ( [Date]; "Q" )
)

Step 2 Adjust sort orders

Power BI sorts attribute values alphabetically by default, so for example the names of the months would be sorted like this: April, August, December and so on. But you can easily fix this. Click on the “Sort By Column” button and choose the appropriate column to sort by. For MonthNameShort this would be MonthNumber.

151013e

And that’s it! You can now create a complete date table in Power BI, using the new calculated table feature in Power BI Desktop, in just a few minutes.

 

Download the DateTablePowerBISteps.pbix file below.