Returns a set of members ending either at the specified member or at the current member in the time dimension.
Syntax
LastPeriods ( numeric value expression [, member [, hierarchy ] ] )
Parameter | Description |
---|---|
numeric value expression | The number of members to return (see MDX Grammar Rules). If negative, member is treated as the starting point. |
Optional. A member expression. | |
Optional. A specific hierarchy within the time dimension. |
Example
Lastperiods(3, Apr) returns the set {Feb, Mar, Apr}.
Lastperiods(-3, Apr) returns the set {Apr, May, Jun}.
Lastperiods(1, Apr) returns a set of one member: {Apr}.
Lastperiods(0, Apr) returns an empty set.
Lastperiods(5, Apr) returns the set {Jan, Feb, Mar, Apr}. Note that the output set has only four members.
The following query:
WITH MEMBER [Measures].[Rolling Sales] AS 'Avg ( LastPeriods (3, [Year].Currentmember ), [Measures].[Sales] )' SELECT {[Measures].[Sales], [Measures].[Rolling Sales]} ON COLUMNS, Descendants ([Year].[Qtr2]) ON ROWS FROM Sample.Basic WHERE [Product].[Root Beer]
returns the grid:
(axis) | Sales | Rolling Sales |
---|---|---|
Qtr2 | 27401 | 27014 |
Apr | 8969 | 8960 |
May | 9071 | 8997 |
Jun | 9361 | 9133.667 |
See Also