Database Reference
In-Depth Information
Let us comment this code:
• The return value is a Set, an MDX set object, from Microsoft.
AnalysisServices.AdomdServer . This means that the return value of
the function can be used directly in our MDX expression; it is much more
efficient than returning a string from the function and then casting that
string to a set using the StrToSet function.
The local variable UserName is calculated using the AdomdServer
Expression object. Expression takes any valid MDX expression and, when
evaluated, will return the value of the MDX expression. We use it to return
the value of the UserName MDX function.
The local variable members is assigned the set of all members from Sales
Territory Country . We use this variable to iterate over all members of the
hierarchy and decide whether they will be visible or not.
° Context : This is an AdomdServer object that exposes the context of
the current query; among other things, it lets us interact with the cube
currently being queried. Context.CurrentCube exposes dimensions,
measure groups and other metadata.
° Dimensions : This is a collection of all the dimensions on the cube. We
use it to select the Sales Territory dimension.
° AttributeHierarchies : This is a collection containing all the
hierarchies of a dimension, from which we select the Sales
Territory Country hierarchy.
° Levels : This contains the levels in the hierarchy. For user hierarchies
it might contain several levels, for attribute hierarchies it normally
contains two levels: one is the All level, the second one is the level of
the other members on the hierarchy. We are interested in the second
level to get the different countries.
° GetMembers : This returns the list of all the members at the
specified level.
Since we want to return a set, we use the AdomdServer helper object
SetBuilder , which lets us create a set and add items to it.
 
Search WWH ::




Custom Search