PrevMember
Using the order of members existing in an Essbase database outline, the MDX PrevMember function returns the previous member along the same generation or level.
Note:
When multiple hierarchies are enabled, this function returns NULL when the source member is in one hierarchy and the result member belongs to a different hierarchy.
Syntax
member.PrevMember [( layertype ) ]
PrevMember ( member [,layertype ] )
Parameters
- member
-
The starting member from which PrevMember counts one member back.
- layertype
-
GENERATION
orLEVEL
. The default is Generation.
Example
Example 1
The following expression
[Jun].prevmember
returns the member that is 1 step prior to Jun:
[May]
Example 2
The following query
/*
For January, PrevMember doesn't exist
For December, NextMember doesn't exist
*/
WITH
MEMBER
[Measures].[Delta from Previous Month]
AS
' [Measures].[Sales] -
([Measures].[Sales],[Year].CurrentMember.PrevMember)
'
MEMBER [Measures].[Delta from Next Month]
AS
' [Measures].[Sales] -
([Measures].[Sales], [Year].CurrentMember.NextMember)
'
SELECT
{ [Measures].[Sales],
[Measures].[Delta from Previous Month],
[Measures].[Delta from Next Month]
}
ON COLUMNS,
[Year].Levels(0).Members
ON ROWS
FROM Sample.Basic
WHERE
(
[Scenario].[Actual],
[Market].[East],
[Product].[100]
)
Returns the grid:
Table 4-123 Output Grid from MDX Example
(axis) | Sales | Delta from Previous Month | Delta from Next Month |
---|---|---|---|
Jan | 2105 | 2105 | 44 |
Feb | 2061 | -44 | -65 |
Mar | 2126 | 65 | -132 |
Apr | 2258 | 132 | -89 |
May | 2347 | 89 | -278 |
Jun | 2625 | 278 | -110 |
Jul | 2735 | 110 | 62 |
Aug | 2673 | -62 | 311 |
Sep | 2362 | -311 | 268 |
Oct | 2094 | -268 | 28 |
Nov | 2066 | -28 | -222 |
Dec | 2288 | 222 | 2288 |