Dense Rank version of Rank function does not give consecutive ranking. And my ques. is not why, but how to get consecutive dense rank?
Hello All, The 3 argument version of Rank() function assigns the same rank to all elements who shares the same value and that is fine. But after, that does not have +1 rank, but there is always a gap in rank. This jump from 1 to 4 is not desired output for me. If someone asks that which are top 2 true elements, answer is Top 1 position is shared by [A,B and C] and 2nd position is D. Similarly, if someone asks who is at 2nd position, result from MDX says, no one is at 2nd position. This is just the sample to illustrate my question. In my SSRS report, I am dealing with Top 5,10,15,50,100 or 150. Please let me know your thoughts how can I generate incremental dense rank using MDX. Thanks Kindly, Jai
November 15th, 2012 9:23am

Hi Jai, Rank(MDX) is used to returns the one-based rank of a specified tuple in a specified set. As per my understanding, there is not Dense_Rank() function in MDX function reference currently. To work around this issue, please refer to the following MDX query. WITH MEMBER [Measures].[Rank] AS Rank ( [Product].[Model Name].CurrentMember, [Product].[Model Name].[Model Name], [Measures].[ORDER Count] ) SET [Sorted Models] AS ORDER ( [Product].[Model Name].[Model Name] ,[Measures].[ORDER Count] ,BDESC ) MEMBER [Measures].[Previous Model INDEX] AS ( Rank ( [Product].[Model Name].CurrentMember, [Sorted Models] ) - 2 ) MEMBER [Measures].[Dense Rank] AS Case When [Measures].[Rank] = 1 Then 1 Else ( [Sorted Models].Item([Measures].[Previous Model INDEX]), [Measures].[Dense Rank] ) + Iif ( ( [Sorted Models].Item([Measures].[Previous Model INDEX]), [Measures].[ORDER Count] ) = [Measures].[ORDER Count] ,0 ,1 ) End SELECT { [Measures].[Rank], [Measures].[Dense Rank] } ON 0, { [Sorted Models] } ON 1 FROM [Adventure Works] Since the issue regards MDX and Analysis Services. I suggestion you post the question in the SQL Server Analysis Services forums at http://social.msdn.microsoft.com/Forums/en/sqlanalysisservices/threads/. It is appropriate and more experts will assist you. Regards, Fanny LiuFanny Liu TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
November 16th, 2012 5:23am

Thanks Fanny Liu, I meant 3 agrument version of Rank function as dense rank. but in real sense, it (3 agrument version of Rank function) does not seems useful. There should have been some direct function to acheive this. Your solution is indeed helpful but it seems a programming approach like "for loop". But anyway, it worked well for me as expected. It is always good to have something instead of nothing. Thank you very much. -Jai
November 19th, 2012 12:07am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics