Time Intelligence Generator
Pick a base measure and the comparisons you need: year to date, prior year, growth, rolling windows. Get the DAX as separate measures or as one calculation group, and see what each one returns before you paste it.
One measure each, for Home → New measure. Or add them all at once with the DAX query view script below.
Total Sales YTD
Total Sales YTD =
CALCULATE([Total Sales], DATESYTD('Date'[Date]))Total Sales PY
Total Sales PY =
CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))Total Sales PYTD
Total Sales PYTD =
CALCULATE([Total Sales YTD], SAMEPERIODLASTYEAR('Date'[Date]))Total Sales YoY %
Total Sales YoY % =
VAR CurrentValue = [Total Sales]
VAR PriorValue = [Total Sales PY]
RETURN
IF(NOT ISBLANK(CurrentValue), DIVIDE(CurrentValue - PriorValue, PriorValue))Total Sales Rolling 12M
Total Sales Rolling 12M =
CALCULATE([Total Sales], DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -12, MONTH))All at once: DAX query view
Open DAX query view, paste, and run it to check the numbers. Then click the Update model link above the measures to add them to the Sales table.
DEFINE
MEASURE 'Sales'[Total Sales YTD] = CALCULATE([Total Sales], DATESYTD('Date'[Date]))
MEASURE 'Sales'[Total Sales PY] = CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))
MEASURE 'Sales'[Total Sales PYTD] = CALCULATE([Total Sales YTD], SAMEPERIODLASTYEAR('Date'[Date]))
MEASURE 'Sales'[Total Sales YoY %] =
VAR CurrentValue = [Total Sales]
VAR PriorValue = [Total Sales PY]
RETURN
IF(NOT ISBLANK(CurrentValue), DIVIDE(CurrentValue - PriorValue, PriorValue))
MEASURE 'Sales'[Total Sales Rolling 12M] = CALCULATE([Total Sales], DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -12, MONTH))
-- Assumes a Year column on the date table; swap in any column you have
EVALUATE
SUMMARIZECOLUMNS(
'Date'[Year],
"Total Sales", [Total Sales],
"Total Sales YTD", [Total Sales YTD],
"Total Sales PY", [Total Sales PY],
"Total Sales PYTD", [Total Sales PYTD],
"Total Sales YoY %", [Total Sales YoY %],
"Total Sales Rolling 12M", [Total Sales Rolling 12M]
)Preview
What these return by month for a made-up Total Sales, with 2024–2025 behind it for the prior-year and rolling windows. At month level, month-to-date equals the month itself; it differs only on daily rows.
| Month | Total Sales | Total Sales YTD | Total Sales PY | Total Sales PYTD | Total Sales YoY % | Total Sales Rolling 12M |
|---|---|---|---|---|---|---|
| Jan 2026 | 9,797 | 9,797 | 9,210 | 9,210 | 6.4% | 133,964 |
| Feb 2026 | 9,048 | 18,845 | 8,508 | 17,718 | 6.3% | 134,504 |
| Mar 2026 | 11,240 | 30,085 | 10,568 | 28,286 | 6.4% | 135,176 |
| Apr 2026 | 11,823 | 41,908 | 10,584 | 38,870 | 11.7% | 136,415 |
| May 2026 | 11,950 | 53,858 | 11,236 | 50,106 | 6.4% | 137,129 |
| Jun 2026 | 11,948 | 65,806 | 11,232 | 61,338 | 6.4% | 137,845 |
| Jul 2026 | 10,672 | 76,478 | 10,035 | 71,373 | 6.3% | 138,482 |
| Aug 2026 | 11,122 | 87,600 | 10,457 | 81,830 | 6.4% | 139,147 |
| Sep 2026 | 12,667 | 100,267 | 11,340 | 93,170 | 11.7% | 140,474 |
| Oct 2026 | 12,888 | 113,155 | 12,118 | 105,288 | 6.4% | 141,244 |
| Nov 2026 | 14,099 | 127,254 | 13,254 | 118,542 | 6.4% | 142,089 |
| Dec 2026 | 15,776 | 143,030 | 14,835 | 133,377 | 6.3% | 143,030 |
Before these will work
Datehas to be marked as a date table, with one row for every day and no gaps. If you don't have one yet, the Date Table Generator builds it.- Visuals must slice by columns from that date table, not by a date column on the fact table, or the time shifts have nothing to move.
- Format
Total Sales YoY %as a percentage.
Free, with no sign-in and no request limit. Everything runs in your browser, and nothing you type is sent anywhere.
Measures or a calculation group? Separate measures are simplest when you only need these comparisons for one or two base measures. Once you need YTD and prior year for Sales, Cost, Margin, and Units, a calculation group writes each calculation once and applies it to all of them.
Want to understand what these functions actually do? See Time Intelligence and the DAX Time Intelligence Cheat Sheet.