SAMEPERIODLASTYEAR

The SAMEPERIODLASTYEAR function returns a table containing a column of dates that match those involved in the current context, shifted back one year.

Syntax

SAMEPERIODLASTYEAR(
    dates
)

Parameters
  • dates: Column containing dates.
Returned value

The SAMEPERIODLASTYEAR function returns a table.

Additional Information

The dates argument can be a reference to a column containing dates, an expression that returns a table with a single column containing dates, or a Boolean expression that defines a table with a single column containing dates.

The result returned by this function is the same as that returned by the DATEADD function, specifying as a period to add a year back in time:

DATEADD (dates, -1, YEAR)

Examples

If, in a table containing sales information, we define the measure:

Ventas = SUM(FactSales[SalesAmount])

...calculating the sum of sales in the period involved in the context, we can show the sales by year and month in a matrix type visualization:

SAMEPERIODLASTYEAR function. Example of use

We can then create a measure to calculate sales for the same period as the one involved in the context a year earlier:

Ventas año anterior = CALCULATE([Ventas], SAMEPERIODLASTYEAR(DimDate[Datekey]))

If we take this measure to the previous matrix, we obtain the following:

SAMEPERIODLASTYEAR function. Example of use

It can be seen how, indeed, this last measure returns the sum of sales for the previous year.

Related functions
Category
Time intelligence
Submitted by admin on Tue, 12/04/2018 - 11:33