lastperiods Function
Function:
Lastperiods
Syntax:
Sum(lastperiods( n , <Time Dimension Name>.currentmember), [Measures].[<measure name>])
Description:
This function enables you to aggregate the last « n » periods. If the Time Dimension is the year, we get the sum for the year and can easily compare totals for several years. Note that other aggregate functions can also be used such as AVG (Average), MIN (Minimum), MAX (Maximum), MEDIAN (Median) etc.
Example: here the « Time Dimension Name » dimension is the DATE.[by Month] dimension with n = 12 and the « measure name » measure is the QTY field (Quantity). We get the sum for the last 12 months.
Sum(lastperiods(12, DATE.[by Month].currentmember), [Measures].[QTY])