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 ...

Get MDX with Microsoft SQL Server 2016 Analysis Services Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.