SAMEPERIODLASTYEAR
The dates in the filter context moved back one year.
Group: Time intelligence. Compatible with DAX.
Syntax
SAMEPERIODLASTYEAR ( <dates> )
| Parameter | Type | Description |
|---|---|---|
dates | Dates | A column of dates of the model, such as Sales[Month], or the name of a calendar defined in the model. |
Returns
Table. The dates of the filter context a year earlier, as far as the column holds them.
Remarks
- It says the same as
DATEADD ( dates, -1, YEAR ), with the same rules: 29 February goes to 28 February, and a whole month goes to the whole month. - Only dates the column holds come back: a date the move or the period lands on that the column lacks is left out, and when none is left the table is empty. A business day a year back can be a weekend: on such a column the comparison may miss a day.
- Given a column, it reads the dates visible in the current filter context; in a row context, such as
ADDCOLUMNS, the row becomes a filter first, so each row sees its own dates. - The selection must be one unbroken run of the column's dates, except on a complete calendar column.
Examples
Liters against the same month a year before
EVALUATE
ADDCOLUMNS (
DATESBETWEEN ( Sales[Month], DATE ( 2025, 1, 1 ), DATE ( 2025, 3, 1 ) ),
"Liters", [Liters sold],
"A year before", CALCULATE ( [Liters sold], SAMEPERIODLASTYEAR ( Sales[Month] ) )
)
ORDER BY Sales[Month]
| Sales[Month] | Liters | A year before |
|---|---|---|
| 2025-01-01 | 44635 | 42637 |
| 2025-02-01 | 44831 | 41966 |
| 2025-03-01 | 43593 | 43893 |
A week of business days
14 to 18 September 2026 a year back: 14 September 2025 was a Sunday, so four days come back.
EVALUATE
CALCULATETABLE (
SAMEPERIODLASTYEAR ( Prices[Date] ),
DATESBETWEEN ( Prices[Date], DATE ( 2026, 9, 14 ), DATE ( 2026, 9, 18 ) )
)
ORDER BY Prices[Date]
| Prices[Date] |
|---|
| 2025-09-15 |
| 2025-09-16 |
| 2025-09-17 |
| 2025-09-18 |