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 2012 instance. Click on the New Query button and check that the target database is Adventure Works DW 2012.
Here's the query we'll start from:
WITH MEMBER [Measures].[Level] AS [Sales Territory].[Sales Territory] .CurrentMember.Level.Ordinal SELECT { [Measures].[Level], [Measures].[Reseller Sales Amount] } ON 0, { [Sales Territory].[Sales Territory].AllMembers } ON 1 FROM [Adventure...