This is the final recipe in our series of relative calculations. In this recipe, we're going to show how to calculate the rank among siblings, the rank on a level, and the rank in the entire hierarchy. A good introduction is given in the first recipe of this series, Calculating various percentages. Therefore, it is recommended that you read all three recipes in this series in order to get a better picture of the possibilities and specifics of calculating relative percentages, averages, and ranks.
Start SQL Server Management Studio and connect to your SSAS 2016 instance. Click on the New Query button and check that the target database is Adventure Works DW 2016.
Here's the query we'll start from:
WITH MEMBER ...