Time intelligence

Sales since the start of the year, the same month last year, the previous month: in DAX these comparisons are called time intelligence. The functions shift the days in the filter, and CALCULATE uses them.

In short: TOTALYTD([Total Sales], 'Date'[Date]) for sales since the start of the year, CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date])) for the previous year, CALCULATE([Total Sales], DATEADD('Date'[Date], -1, MONTH)) for the previous month. All of them need the date column of a date table.

Before this: Date table (level 3) and RANKX and TOPN.

Try it now

Task Create the measure "Sales YTD": sales from 1 January up to the end of each month (year to date). The matrix is filtered to 2026.

Sales 120 rows, 7 columns
OrderIDOrderDateShipDateProductIDRegionIDQuantityAmount
13 Oct 20266 Oct 20261221798
29 Nov 202519 Nov 20252351145
320 Sep 202627 Sep 2026544596
416 Jun 20252 Jul 20252151145
526 Mar 202631 Mar 20261343596
64 Dec 202510 Dec 2025545745
78 Jul 202526 Jul 2025614196
820 Feb 20251 Mar 202532359.7
99 Dec 202524 Dec 202562298
1012 Aug 202625 Aug 2026212458
117 Sep 202612 Sep 2026542298
122 Mar 202614 Mar 2026623147

Showing the first 12 of 120 rows.

Measures: [Total Sales]

Product 6 rows, 4 columns
ProductIDProductCategoryPrice
1LaptopHardware899
2MonitorHardware229
3MouseAccessories19.9
4KeyboardAccessories39.9
5Office suiteSoftware149
6AntivirusSoftware49
Region 4 rows, 2 columns
RegionIDRegion
1North
2South
3West
4East
Date 730 rows, 4 columns
DateYearMonthMonthName
1 Jan 202520251Jan
2 Jan 202520251Jan
3 Jan 202520251Jan
4 Jan 202520251Jan
5 Jan 202520251Jan
6 Jan 202520251Jan
7 Jan 202520251Jan
8 Jan 202520251Jan
9 Jan 202520251Jan
10 Jan 202520251Jan
11 Jan 202520251Jan
12 Jan 202520251Jan

Showing the first 12 of 730 rows.

How time intelligence works

The March 2026 row filters the date table to the days from 1 to 31 March 2026. A time function takes these days and builds new ones: DATESYTD the days from 1 January to 31 March, SAMEPERIODLASTYEAR the days in March 2025. CALCULATE then evaluates the measure with the new days. TOTALYTD is the short form of CALCULATE(…, DATESYTD(…)).

That is why you need a separate date table with every day and a relationship to the fact table. A date column in the fact table itself has gaps on days without orders.

Previous year and previous month

Task Create the measure "Sales PY": [Total Sales] for the same period one year earlier. The matrix shows 2026; the measure should return the 2025 values.

Sales 120 rows, 7 columns
OrderIDOrderDateShipDateProductIDRegionIDQuantityAmount
13 Oct 20266 Oct 20261221798
29 Nov 202519 Nov 20252351145
320 Sep 202627 Sep 2026544596
416 Jun 20252 Jul 20252151145
526 Mar 202631 Mar 20261343596
64 Dec 202510 Dec 2025545745
78 Jul 202526 Jul 2025614196
820 Feb 20251 Mar 202532359.7
99 Dec 202524 Dec 202562298
1012 Aug 202625 Aug 2026212458
117 Sep 202612 Sep 2026542298
122 Mar 202614 Mar 2026623147

Showing the first 12 of 120 rows.

Measures: [Total Sales]

Product 6 rows, 4 columns
ProductIDProductCategoryPrice
1LaptopHardware899
2MonitorHardware229
3MouseAccessories19.9
4KeyboardAccessories39.9
5Office suiteSoftware149
6AntivirusSoftware49
Region 4 rows, 2 columns
RegionIDRegion
1North
2South
3West
4East
Date 730 rows, 4 columns
DateYearMonthMonthName
1 Jan 202520251Jan
2 Jan 202520251Jan
3 Jan 202520251Jan
4 Jan 202520251Jan
5 Jan 202520251Jan
6 Jan 202520251Jan
7 Jan 202520251Jan
8 Jan 202520251Jan
9 Jan 202520251Jan
10 Jan 202520251Jan
11 Jan 202520251Jan
12 Jan 202520251Jan

Showing the first 12 of 730 rows.

This exercise is part of Premium.

Premium unlocks every exercise in every lesson, unlimited practice with fresh tasks and the final test with certificate.

See Premium Already Premium? Log in

The first exercise in this lesson is free.

SAMEPERIODLASTYEAR shifts by exactly one year. DATEADD('Date'[Date], -1, YEAR) gives the same result here; DATEADD can also shift by days, months or quarters. PREVIOUSYEAR is different: it always returns the whole previous year, so every month row shows the same number.

Task Create the measure "Sales PM": [Total Sales] of the previous month, using DATEADD. January 2026 should therefore show December 2025.

Sales 120 rows, 7 columns
OrderIDOrderDateShipDateProductIDRegionIDQuantityAmount
13 Oct 20266 Oct 20261221798
29 Nov 202519 Nov 20252351145
320 Sep 202627 Sep 2026544596
416 Jun 20252 Jul 20252151145
526 Mar 202631 Mar 20261343596
64 Dec 202510 Dec 2025545745
78 Jul 202526 Jul 2025614196
820 Feb 20251 Mar 202532359.7
99 Dec 202524 Dec 202562298
1012 Aug 202625 Aug 2026212458
117 Sep 202612 Sep 2026542298
122 Mar 202614 Mar 2026623147

Showing the first 12 of 120 rows.

Measures: [Total Sales]

Product 6 rows, 4 columns
ProductIDProductCategoryPrice
1LaptopHardware899
2MonitorHardware229
3MouseAccessories19.9
4KeyboardAccessories39.9
5Office suiteSoftware149
6AntivirusSoftware49
Region 4 rows, 2 columns
RegionIDRegion
1North
2South
3West
4East
Date 730 rows, 4 columns
DateYearMonthMonthName
1 Jan 202520251Jan
2 Jan 202520251Jan
3 Jan 202520251Jan
4 Jan 202520251Jan
5 Jan 202520251Jan
6 Jan 202520251Jan
7 Jan 202520251Jan
8 Jan 202520251Jan
9 Jan 202520251Jan
10 Jan 202520251Jan
11 Jan 202520251Jan
12 Jan 202520251Jan

Showing the first 12 of 730 rows.

This exercise is part of Premium.

Premium unlocks every exercise in every lesson, unlimited practice with fresh tasks and the final test with certificate.

See Premium Already Premium? Log in

The first exercise in this lesson is free.

In real Power BI

  1. Check that the date table is marked as a date table and related to the fact table.
  2. Create a measure, for example Sales YTD = TOTALYTD([Total Sales], 'Date'[Date]).
  3. Put it in a matrix with 'Date'[Year] and 'Date'[Month]. For many cases, New quick measure offers ready-made templates whose DAX you can look at afterwards.

Common mistakes

The fact table's date column

TOTALYTD([Total Sales], Sales[OrderDate]) looks right but returns only that month's sales in every month row: the date table's filter on the month stays, only the order dates are widened. Always use the date table's column.

Previous year without data

For 2025, [Sales PY] shows blank cells because the model contains no 2024. That is correct, not an error.

FAQ

What about the fiscal year?

TOTALYTD and DATESYTD have another argument for the fiscal year end, for example 30 June.

Why does the total row show the full year for YTD?

The total row filters the whole year. Year to date up to its last day is then the whole year.

Up next: LOOKUPVALUE and RELATEDTABLE

Looking up values like VLOOKUP and counting across relationships.

Next lesson

Write to us

Choose language

Select your preferred language