Home

SAMEPERIODLASTYEARDateDate

SAMEPERIODLASTYEAR is a DAX time intelligence function used in Power BI, SQL Server Analysis Services, and Excel data models. It returns a table of dates that corresponds to the same period in the previous year, based on the dates in the current filter context.

The function is commonly used to enable year-over-year comparisons for measures such as sales, revenue, or units.

Syntax and usage: SAMEPERIODLASTYEAR(<dates>) where <dates> is a date column from a date table or a column

Example: Revenue LY = CALCULATE(SUM(Sales[Revenue]), SAMEPERIODLASTYEAR('Date'[Date]))

This computes total revenue for the same dates in the prior year, relative to the current calendar

Requirements and considerations: A proper, continuous date table is required, and it must be related to the

See also: PARALLELPERIOD, DATEADD, SAMEPERIODLASTMONTH, SAMEPERIODLASTQUARTER.

When
placed
inside
a
CALCULATE
expression,
SAMEPERIODLASTYEAR
shifts
the
active
date
context
one
year
back,
allowing
a
measure
to
be
evaluated
for
the
same
calendar
period
in
the
previous
year.
that
represents
a
continuous
date
range.
The
function
returns
a
single-column
table
of
dates
that
align
with
the
previous
year
for
the
dates
currently
filtered.
selection.
fact
table
containing
the
measures.
The
date
table
should
be
marked
as
a
date
table
for
correct
behavior.
Because
SAMEPERIODLASTYEAR
relies
on
calendar
dates,
it
naturally
handles
leap
years
and
varying
month
lengths.
For
fiscal
calendars
or
non-standard
periods,
alternatives
like
PARALLELPERIOD
or
DATEADD
with
a
custom
date
column
may
be
more
appropriate.