Domain 2 β€” Module 6 of 7 86%
13 of 26 overall
Domain 2: Model the Data Free ⏱ ~14 min read

Time Intelligence & Calculation Groups

Master time intelligence DAX functions β€” year-to-date, same period last year, semi-additive measures β€” and learn how calculation groups reduce measure duplication.

Comparing across time

Simple explanation

Think about your bank account. You don’t just want to know your balance today β€” you want to know if it’s higher than last month, how much you’ve spent year-to-date, and whether you’re on track compared to the same time last year.

Time intelligence DAX functions let you ask these same questions about your business data: year-to-date revenue, this quarter vs last quarter, running totals over months. They all require a proper date table (covered in the Date Tables module).

Essential time intelligence functions

Year-to-date

YTD Revenue = 
TOTALYTD(
    SUM(Sales[Revenue]),
    'Date'[Date]
)

Or equivalently using CALCULATE + DATESYTD:

YTD Revenue = 
CALCULATE(
    SUM(Sales[Revenue]),
    DATESYTD('Date'[Date])
)

Riley at Coastal Fresh (πŸ›’) puts this in a matrix with months as rows. In March, it shows Jan + Feb + Mar cumulative revenue. In June, it shows Jan through June.

Same period last year

Revenue Last Year = 
CALCULATE(
    SUM(Sales[Revenue]),
    SAMEPERIODLASTYEAR('Date'[Date])
)
YoY Change % = 
VAR Current = SUM(Sales[Revenue])
VAR LastYear = CALCULATE(SUM(Sales[Revenue]), SAMEPERIODLASTYEAR('Date'[Date]))
RETURN
    DIVIDE(Current - LastYear, LastYear)

Kenji at Apex Manufacturing (🏭) uses YoY Change to compare this April’s production to last April’s.

DATEADD: flexible period shifting

Revenue 3 Months Ago = 
CALCULATE(
    SUM(Sales[Revenue]),
    DATEADD('Date'[Date], -3, MONTH)
)

DATEADD is more flexible than SAMEPERIODLASTYEAR β€” you can shift by any number of days, months, quarters, or years.

Common time intelligence functions

FunctionWhat It Does
TOTALYTD(measure, date)Year-to-date accumulation
TOTALQTD(measure, date)Quarter-to-date
TOTALMTD(measure, date)Month-to-date
SAMEPERIODLASTYEAR(date)Shifts dates back one year
DATEADD(date, intervals, type)Shifts dates by any amount
PREVIOUSMONTH(date)Returns dates from the previous month
PREVIOUSQUARTER(date)Returns dates from the previous quarter
DATESYTD(date)Returns year-to-date dates
DATESINPERIOD(date, start, intervals, type)Returns a custom rolling window
Exam tip: time intelligence requirements

Time intelligence functions work best with:

  1. A marked date table (Table tools β†’ Mark as date table)
  2. Contiguous dates β€” no gaps in the date column
  3. The date column should be Date or Date/Time data type

If time intelligence returns unexpected results, check these requirements first. Power BI’s auto date/time feature provides basic time intelligence without a custom date table, but a dedicated date table gives you full control and is the exam-expected approach.

Semi-additive measures

Some values shouldn’t be summed across time. Kenji tracks inventory levels β€” if he has 500 units on Monday, 480 on Tuesday, and 510 on Wednesday, the weekly inventory isn’t 1,490 (the sum). It’s 510 (the latest value).

Current Inventory = 
CALCULATE(
    SUM(Inventory[Quantity]),
    LASTDATE('Date'[Date])
)

Or using CLOSINGBALANCEMONTH for month-end snapshots:

Month End Balance = 
CLOSINGBALANCEMONTH(
    SUM(Accounts[Balance]),
    'Date'[Date]
)

Semi-additive examples: inventory counts, account balances, headcount, stock prices β€” anything where summing across time gives a meaningless number.

Semi-additive measures need LASTDATE or CLOSINGBALANCEMONTH β€” never SUM across time
Measure TypeSum Across Time?ExampleDAX Approach
AdditiveYes βœ“Revenue, units sold, hours workedSUM() works fine
Semi-additiveNo βœ—Inventory, headcount, account balanceUse LASTDATE, CLOSINGBALANCEMONTH, or LASTNONBLANK
Non-additiveNo βœ—Ratios, percentages, averagesCalculate from additive components

Calculation groups

Calculation groups let you apply time intelligence (or any transformation) to multiple measures without duplicating code.

Without calculation groups, Nadia at Prism Agency (πŸ“Š) would need:

  • Revenue YTD, Clicks YTD, Impressions YTD, Spend YTD
  • Revenue LY, Clicks LY, Impressions LY, Spend LY
  • Revenue YoY%, Clicks YoY%, Impressions YoY%, Spend YoY%

That’s 12 measures for 4 base measures Γ— 3 time views. With 10 base measures, it becomes 30 measures.

Calculation groups define the time transformation ONCE:

Calculation ItemLogic
CurrentSELECTEDMEASURE() (no change)
YTDCALCULATE(SELECTEDMEASURE(), DATESYTD(β€˜Date’[Date]))
Prior YearCALCULATE(SELECTEDMEASURE(), SAMEPERIODLASTYEAR(β€˜Date’[Date]))
YoY %(Current - Prior Year) / Prior Year

Now any measure can use these items: drop the calculation group on a visual, and every measure gets YTD, Prior Year, and YoY% automatically.

How to create calculation groups

Calculation groups are created in Model view β†’ New calculation group (or using external tools like Tabular Editor).

Each calculation group:

  • Has a name (e.g., β€œTime Intelligence”)
  • Contains calculation items (e.g., β€œYTD”, β€œPrior Year”)
  • Uses SELECTEDMEASURE() to reference whatever measure is being modified
  • Appears as a column in the Fields pane that can be placed on visuals

On the exam, know that calculation groups reduce measure proliferation β€” one group with 4 items applied to 10 base measures replaces 40 individual measures.

Knowledge check

Question

What's the difference between TOTALYTD and DATESYTD?

Click or press Enter to reveal answer

Answer

TOTALYTD(measure, dateColumn) is a shortcut that wraps CALCULATE + DATESYTD. DATESYTD(dateColumn) returns the set of year-to-date dates and must be used inside CALCULATE.

Click to flip back

Question

What is a semi-additive measure?

Click or press Enter to reveal answer

Answer

A measure that can be summed across some dimensions (like products or regions) but NOT across time. Examples: inventory counts, account balances, headcount. Use LASTDATE or CLOSINGBALANCEMONTH instead of SUM.

Click to flip back

Question

What does SELECTEDMEASURE() do in a calculation group?

Click or press Enter to reveal answer

Answer

It references whatever base measure is currently being evaluated. This lets a single calculation item (like 'YTD') apply to Revenue, Clicks, Impressions β€” any measure in the model.

Click to flip back

Knowledge Check

Kenji tracks factory inventory. He uses SUM(Inventory[Quantity]) and sees that the monthly total is 15,000 β€” but the actual inventory is 500 units. What went wrong?

Knowledge Check

Which DAX function shifts dates by a flexible number of periods (days, months, quarters, or years)?

Next up: Model Performance Optimisation β€” find and fix slow queries with Performance Analyzer and DAX query view.