Detecting a particular member in a hierarchy
We frequently encounter situations where we need to include or exclude a certain member in a calculation. Our first step is to determine whether the member exists in a hierarchy.
When iterating through a set of hierarchy members, at each step in the iteration, the member being operated upon is the current member. This recipe shows how to determine whether the current member in the query context is a particular member that we are interested in.
Getting ready
Start SQL Server Management Studio and connect to your SSAS 2012 instance. Click on the New Query button and check that the target database is Adventure Works DW 2012.
In this example, we're going to use the Product
dimension. Here's the query we'll start from:
SELECT { } ON 0, { [Product].[Color].AllMembers } ON 1 FROM [Adventure Works]
Once executed, the query returns all product colors, including the root member. The preceding query will return products...