MDAC 2.5 SDK - OLE DB Programmer's Reference
Chapter 24: Multidimensional Expressions
Member Value Expressions
<member>.{PARENT | FIRSTCHILD | LASTCHILD | PREVMEMBER | NEXTMEMBER}
- PREVMEMBER gives the previous member along the level implied by <member>.
- NEXTMEMBER gives the next member along the level implied by <member>.
- FIRSTCHILD returns the first child of a member according to an implicit natural order. (The children of any member are arranged along this natural order.)
- LASTCHILD gives the last child of a member according to the natural order.
- PARENT gives the parent of a member.
<member>.LEAD(<index>)
Gives the member that is <index> positions away along the member's dimension, in the dimension's natural order. The numbering of the positions is zero-based.
The function <member>.LAG is similar, except that it looks in the opposite direction. If <index> is negative, then LEAD becomes LAG, and vice versa.
<dimension>[.CURRENTMEMBER]
Gives the current member along <dimension>. The concept of "currency" occurs in functions such as GENERATE, where the semantics include some form of iteration through members of a set.
<member>.{FIRSTSIBLING | LASTSIBLING}
Returns the first/last sibling at the parent level of the <member>. For example,
May.FIRSTSIBLING
returns April, and the expression
May.LASTSIBLING
returns June (assuming that the parent level is quarters).
ANCESTOR(<member>, <level>)
Returns the ancestor of <member> at the specified level.
COUSIN(<member>, <ancestor_member>)
This function is best illustrated by an example: The expression
COUSIN([1996].March, [1994])
yields the member [1994].March.
The algorithm to evaluate the COUSIN function call is as follows:
COUSIN(<member1>, <member2>)
The three possible scenarios are as follows:
- If the level of <member2> is not at a higher level than <member1>, return immediately. Higher level means a lower level number, because level numbers start at the root (whose level is zero) and increase towards the leaf.
- If <member2> is a direct ancestor of <member1>, <member1> returns.
- Otherwise:
- Each member in the hierarchy has a unique sibling-number associated with it. The sibling-number is the rank of a member among its siblings when the siblings are in natural order.
- Let <ancestor> be a member so that it is the ancestor of <member1> and is a sibling of <member2>.
- Consider the subtree rooted at <ancestor>. Let P denote the set of sibling-numbers of members traversed in the path from <ancestor> to <member1>. For example, if <ancestor> is North America and <member1> is Seattle, then P = {5, 41}, assuming that the rank of USA among all children of North America is 5 and that the rank of Washington state among all children of USA is 41.
- Let <m> be the member obtained by starting at <member2> and traversing the path P. Return <m>.