Lag

Using the order of members existing in a database outline, returns a member that is n steps behind a given member, along the same generation or level (as defined by layertype).

Syntax

member.Lag (index [,layertype ] [, hierarchy ] )
Lag ( member, index [, hierarchy ] )
ParameterDescription

member

The starting member from which .LAG counts to a given number of previous members.

index

A number n representing how many steps prior to <member> to count.

layertype

GENERATION or LEVEL. Generation is the default.

hierarchy

Optional. A specific hierarchy within the time dimension.

Notes

Example

The following expression:

[Jun].lag (3)

returns the member that is 3 steps prior to Jun:

[Mar]

The following expression:

[Jun].lag (-3)

returns the member that is 3 steps following Jun:

[Sep]

For every month, the following query displays the sales and average over the last three months.

WITH MEMBER
 [Measures].[Average Sales in Last 3 months]
AS
'Avg(
     {[Year].CurrentMember,
      [Year].CurrentMember.Lag(1),
      [Year]. CurrentMember.Lag(2)
     }, 
     [Measures].[Sales]
 )'
SELECT 
 {[Measures].[Sales], 
  [Measures].[Average Sales in Last 3 months] 
 } 
ON COLUMNS,
 [Year].Levels(0).Members
ON ROWS
FROM Sample.Basic

This query returns the grid:

(axis)SalesAverage Sales in Last 3 Months
Jan3153831538
Feb2306931803.500
March3221331940
April3291732399.667
May3367432934.667
Jun3508833893
Jul3613434965.333
Aug3600835743.333
Sep3307335071.667
Oct3282833969.667
Nov3197132624
Dec3334232713.667

See Also