Time Intelligence, YTD Analysis and Date Tables

You understand time intelligence functions and build a date table.

You can build YTD, MTD and prior-year comparisons with the help of a date table in Power BI.

Say you want to know how your revenue develops over the course of the year. Or how much better you're doing than last year. Sounds simple, but without a proper date table you won't get there. And what you get instead is this:

  • Your YTD looks fine… but stops on 30 June
  • Your "last year" revenue counts everything from January through December, even when you're filtering on April
  • Your month comparison returns zero because the date can't be found

This happens surprisingly often. Time intelligence in Power BI only works when your model meets a few strict requirements.

Why a date table matters

Power BI has time functions like TOTALYTD() and SAMEPERIODLASTYEAR(). But they only work if you:

  • Have a separate date table

date table

  • Create a relationship between that date table and your fact table (e.g. Verkoopregels[Datum])
  • Only use dates from the date table in visuals and slicers

Using the date column from your transaction data? Then those functions won't work properly. And you'll get wrong totals or empty visuals.

won't work properly

?Knowledge check

Why can't you just use the date column from your fact table for time intelligence?

How to create a date table

The easiest way is with DAX:

dax
Datum = CALENDAR( DATE(2020, 1, 1), DATE(2025, 12, 31) )

Or let Power BI work out the range automatically from your data:

dax
Datum = CALENDARAUTO()

Then add columns for year, month, quarter and so on:

dax
Jaar = YEAR( Datum[Date] )
Maandnummer = MONTH( Datum[Date] )
Maandnaam = FORMAT( Datum[Date], "MMMM" )
Kwartaal = "Q" & FORMAT( Datum[Date], "Q" )
Tip

CALENDARAUTO() scans every date column in your model and builds a table from 1 January of the earliest year to 31 December of the latest year. Handy, but always check that the range is right.

Option 1 - Use a standard template and load it into Power BI

Use the template from the attachment to this lesson. That way you always have a complete date table that keeps itself up to date and meets every requirement.

Option 2, Automatically in DAX:

Then add extra columns such as:

  • Jaar = YEAR([Datum])
  • Maand = FORMAT([Datum], "MMMM")
  • JaarMaand = FORMAT([Datum], "YYYY-MM")
  • Kwartaal = "Q" & FORMAT([Datum], "Q")

Option 3, By hand in Excel (bad idea):

Some people build their own date file in Excel. Don't. Far too error-prone and it doesn't scale.

Building time intelligence measures

Keep reading

Leave your name and email address and you can read the rest

You get the whole lesson right away, and every other lesson stays open after that. No password, no confirmation email.

Your address stays with us. No selling to third parties, and you unsubscribe in one click.