Classic time intelligence
Shift the current date context
A prior-year measure should answer the same period question one year earlier. Time intelligence functions usually return a date table that CALCULATE uses to evaluate a measure over a different period. TOTALYTD instead returns the evaluated expression. Use the isolated Import model in labs/date-time-intelligence/README.md. It has a single active one-to-many relationship from Dates[Date] to Sales[SaleDate], single-direction filtering, no RLS, en-US formula separators, USD whole-dollar amounts and a certified synthetic data cutoff of February 15, 2025. Native Desktop/DAX results are predicted, not executed. Each named measure is created separately. Do not use the auto date hierarchy. Use Dates[Date] for all selection in this lesson. The fixture treats omitted transaction dates before the cutoff as no sales, not missing source days.
Example 1 — Compare matching periods
Create measures individually.
Revenue = SUM(Sales[RevenueUSD])Prior Year Revenue =CALCULATE([Revenue], SAMEPERIODLASTYEAR(Dates[Date]))YoY Growth = DIVIDE([Revenue] - [Prior Year Revenue], [Prior Year Revenue])Filter Dates[Date] to February 1–15, 2025: revenue 120, prior year 80, growth 50%. DATEADD(Dates[Date], -1, YEAR) supplies the equivalent shifted set for this contiguous selection. A prior-year denominator of zero or BLANK makes DIVIDE return BLANK unless an alternate constant is supplied. For a production KPI explicitly decide whether no current data should be treated as zero; the simple formula above assumes the selected current period is known complete.
Example 2 — Year-to-date totals
Revenue YTD = CALCULATE([Revenue], DATESYTD(Dates[Date]))Revenue YTD Alternative = TOTALYTD([Revenue], Dates[Date])Fiscal Revenue YTD = TOTALYTD([Revenue], Dates[Date], "6/30")With February 15, 2025 selected, calendar YTD is 320 and fiscal YTD is 460 (July 1, 2024 to February 15, 2025). The fiscal literal is interpreted in the model/client locale; use en-US for this lab. It is not an instruction to use July fiscal years for every organization. Keep fiscal and Gregorian measures clearly labeled.
Watch for calendar boundaries
Classic DATEADD with a date column can fail for noncontiguous selections. Month-end extensions and leap-day mapping can change the selected dates; do not assume shifting always preserves cardinality. For classic SAMEPERIODLASTYEAR a single February 29, 2024 maps to February 28, 2023; a selection of the final two days of February can extend to the destination month end. Test the returned date sets, not only revenue. The calendar metadata overload can behave differently.
Practice — Compare January
Select January 1–31, 2025. Predict current and prior revenue, growth, Gregorian YTD and fiscal YTD. State the exact periods and explain why comparing January 2025 to all of 2024 is not year-over-year growth for January.
Further official reading
Microsoft Learn: time intelligence functions dax · Microsoft Learn: sameperiodlastyear function dax
These links provide supporting context; the local fixture and its expected results remain unchanged.