O'Reilly logo

MDX with Microsoft SQL Server 2016 Analysis Services Cookbook - Third Edition by Sherry Li, Tomislav Piasevoli

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Calculating various ranks

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.

Getting ready

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required