Time intelligence is the part of DAX that answers business questions: How are we doing this year? vs last year? What's the 30-day moving average? All these formulas rely on one thing — a properly set-up Date table.
You need a Date table
A Date table is a separate dimension with one row per calendar date in your data range. It must:
- Have a contiguous date range — no gaps, even for weekends.
- Be marked as a Date table (Model view → right-click → Mark as date table).
- Be related to your fact table on the date column.
Date =ADDCOLUMNS(CALENDAR(DATE(2022, 1, 1), DATE(2027, 12, 31)),"Year", YEAR([Date]),"Quarter", "Q" & FORMAT([Date], "Q"),"Month", FORMAT([Date], "MMMM"),"Month No", MONTH([Date]),"Year-Mo", FORMAT([Date], "YYYY-MM"),"Weekday", FORMAT([Date], "dddd"),"Is WE", WEEKDAY([Date], 2) > 5)
YTD, MTD, QTD
Sales YTD = TOTALYTD([Total Sales], 'Date'[Date])Sales MTD = TOTALMTD([Total Sales], 'Date'[Date])Sales QTD = TOTALQTD([Total Sales], 'Date'[Date])-- Need a fiscal-year YTD ending in March?Sales FY YTD =TOTALYTD([Total Sales], 'Date'[Date], "31/03")
Year-over-Year & Period-over-Period
-- Same period, one year agoSales LY =CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))-- Year-over-Year %YoY % =DIVIDE([Total Sales] - [Sales LY], [Sales LY])-- Same period, one quarter agoSales QoQ =CALCULATE([Total Sales],PARALLELPERIOD('Date'[Date], -1, QUARTER))-- Same period, one month agoSales MoM =CALCULATE([Total Sales], DATEADD('Date'[Date], -1, MONTH))
Rolling averages
-- Last 7 days rolling sumSales 7D =CALCULATE([Total Sales],DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -7, DAY))-- 7-day rolling averageSales 7D Avg = DIVIDE([Sales 7D], 7)-- Trailing 12 months — common executive KPISales TTM =CALCULATE([Total Sales],DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -12, MONTH))
Fiscal calendars
If your fiscal year doesn't start in January, add a "fiscal year" column to your Date table:
-- Indian FY (April-March)"Fiscal Year" =IF(MONTH([Date]) >= 4,YEAR([Date]),YEAR([Date]) - 1)
Then most "regular" measures work — just slice by Fiscal Year instead of Year.
Production patterns
1. The compact KPI tile
Revenue = [Total Sales]Δ vs LY = DIVIDE([Total Sales] - [Sales LY], [Sales LY])Trend =SWITCH(TRUE(),[Δ vs LY] > 0.05, "▲",[Δ vs LY] < -0.05, "▼","▶")
2. Smart % change formatting
-- Show "—" when there's no comparison periodYoY % =VAR LY = [Sales LY]RETURNIF(ISBLANK(LY) || LY = 0, BLANK(),DIVIDE([Total Sales] - LY, LY))
Key takeaways
- 01A proper Date table (contiguous, marked) is the foundation of all time intelligence.
- 02TOTALYTD / TOTALMTD / TOTALQTD handle period-to-date with one function each.
- 03SAMEPERIODLASTYEAR / DATEADD / PARALLELPERIOD cover all comparison patterns.
- 04DATESINPERIOD beats DATESBETWEEN for rolling windows — it slides automatically.
- 05Wrap with VAR + ISBLANK to handle missing comparison periods elegantly.
