Skip to main content
Albero Academy

Time Intelligence in DAX

YTD, MTD, Same-Period-Last-Year, rolling averages, and the Date table that makes them all work — the recipes analysts ship daily.

Chapter 4Power BI16 min readBeginner friendly
  • #Power BI
  • #DAX
  • #Time Intelligence

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.
DAX · build a date table
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

Text
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

Text
-- Same period, one year ago
Sales LY =
CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))
-- Year-over-Year %
YoY % =
DIVIDE([Total Sales] - [Sales LY], [Sales LY])
-- Same period, one quarter ago
Sales QoQ =
CALCULATE(
[Total Sales],
PARALLELPERIOD('Date'[Date], -1, QUARTER)
)
-- Same period, one month ago
Sales MoM =
CALCULATE([Total Sales], DATEADD('Date'[Date], -1, MONTH))

Rolling averages

Text
-- Last 7 days rolling sum
Sales 7D =
CALCULATE(
[Total Sales],
DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -7, DAY)
)
-- 7-day rolling average
Sales 7D Avg = DIVIDE([Sales 7D], 7)
-- Trailing 12 months — common executive KPI
Sales 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:

Text
-- 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

Text
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

Text
-- Show "—" when there's no comparison period
YoY % =
VAR LY = [Sales LY]
RETURN
IF(ISBLANK(LY) || LY = 0, BLANK(),
DIVIDE([Total Sales] - LY, LY))

Key takeaways

  1. 01A proper Date table (contiguous, marked) is the foundation of all time intelligence.
  2. 02TOTALYTD / TOTALMTD / TOTALQTD handle period-to-date with one function each.
  3. 03SAMEPERIODLASTYEAR / DATEADD / PARALLELPERIOD cover all comparison patterns.
  4. 04DATESINPERIOD beats DATESBETWEEN for rolling windows — it slides automatically.
  5. 05Wrap with VAR + ISBLANK to handle missing comparison periods elegantly.