kohera-logo-regular.svg

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”.

 

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] )
)

 

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.

 

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.

Do you want to see a step-by-step video? Just watch our tutorial below.

If you want to download the DateTablePowerBISteps.pbix, just fill out your details below.

[contact-form-7 id=”3956″ title=”Download Gated File”]

Group of computer programmers working in the office. Focus is on blond woman showing something to her colleague on PC.
Updating your Azure SQL server OAuth2 credentials in Power BI via PowerShell for automation purposes
The better way to update OAuth2 credentials in Power BI is by automating the process of updating Azure SQL Server...
2401-under-memory-pressure-featured-image
Under (memory) pressure
A few weeks ago, a client asked me if they were experiencing memory pressure and how they could monitor it...
2402-fabric-lakehouse-featured-image
Managing files from other devices in a Fabric Lakehouse using the Python Azure SDK
In this blogpost, you’ll see how to manage files in OneLake programmatically using the Python Azure SDK. Very little coding...
2319-blog-database-specific-security-featured-image
Database specific security in SQL Server
There are many different ways to secure your database. In this blog post we will give most of them a...
kohera-2312-blog-sql-server-level-security-featured-image
SQL Server security made easy on the server level
In this blog, we’re going to look at the options we have for server level security. In SQL Server we...
blog-security_1
Microsoft SQL Server history
Since its inception in 1989, Microsoft SQL Server is a critical component of many organizations' data infrastructure. As data has...