Advanced Time Intelligence Functions
Time intelligence functions allow you to compare data across time periods — a core requirement in business reporting.
Pre-requisites for Time Intelligence
- A dedicated Date table must exist in the model
- The Date table must have a column marked as the Date column
- The Date table must contain continuous dates (no gaps)
- The Date table must be related to the fact table
Creating a Date Table:
DateTable =
ADDCOLUMNS(
CALENDAR(DATE(2020,1,1), DATE(2025,12,31)),
"Year", YEAR([Date]),
"Month", MONTH([Date]),
"MonthName", FORMAT([Date], "MMMM"),
"Quarter", "Q" & FORMAT([Date], "Q"),
"Day", DAY([Date]),
"Weekday", FORMAT([Date], "dddd")
)
SAMEPERIODLASTYEAR()
Returns the same dates from the previous year.
Syntax: SAMEPERIODLASTYEAR(Dates)
Example:
Sales Last Year = CALCULATE([Total Sales], SAMEPERIODLASTYEAR(Dates[Date]))
Year-Over-Year Growth:
YoY Growth =
VAR CurrentYear = [Total Sales]
VAR LastYear = CALCULATE([Total Sales], SAMEPERIODLASTYEAR(Dates[Date]))
RETURN
DIVIDE(CurrentYear - LastYear, LastYear)
PARALLELPERIOD()
Returns a set of dates shifted by a specified number of intervals.
Syntax: PARALLELPERIOD(Dates, NumberOfIntervals, Interval)
Examples:
Sales Last Quarter = CALCULATE([Total Sales], PARALLELPERIOD(Dates[Date], -1, QUARTER))
Sales Two Years Ago = CALCULATE([Total Sales], PARALLELPERIOD(Dates[Date], -2, YEAR))
YTD, MTD, QTD — Period-to-Date Functions
These functions calculate cumulative totals from the start of the period to the current date.
| Function | Description |
|---|---|
TOTALYTD() | Year-to-Date total |
TOTALMTD() | Month-to-Date total |
TOTALQTD() | Quarter-to-Date total |
DATESYTD() | Returns YTD dates (use inside CALCULATE) |
DATESMTD() | Returns MTD dates |
DATESQTD() | Returns QTD dates |
Examples:
YTD Sales = TOTALYTD([Total Sales], Dates[Date])
MTD Sales = TOTALMTD([Total Sales], Dates[Date])
QTD Sales = TOTALQTD([Total Sales], Dates[Date])
Using CALCULATE + DATESYTD (alternative approach):
YTD Sales = CALCULATE([Total Sales], DATESYTD(Dates[Date]))
PREVIOUSMONTH(), PREVIOUSQUARTER(), PREVIOUSYEAR()
| Function | Returns |
|---|---|
PREVIOUSMONTH() | Dates from the previous month |
PREVIOUSQUARTER() | Dates from the previous quarter |
PREVIOUSYEAR() | Dates from the previous year |
NEXTMONTH() | Dates from the next month |
NEXTQUARTER() | Dates from the next quarter |
NEXTYEAR() | Dates from the next year |
Example:
Previous Month Sales = CALCULATE([Total Sales], PREVIOUSMONTH(Dates[Date]))
Time Intelligence Summary Table
| Function | Purpose | Example |
|---|---|---|
SAMEPERIODLASTYEAR() | Same period, last year | YoY comparison |
PARALLELPERIOD() | Shift by N intervals | QoQ, custom periods |
TOTALYTD() | Cumulative year total | Running YTD revenue |
TOTALMTD() | Cumulative month total | MTD performance |
TOTALQTD() | Cumulative quarter total | QTD tracking |
PREVIOUSMONTH() | Previous month dates | Month-over-month |
DATEADD() | Flexible date shift | Any period comparison |