Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

Removing Ranking Duplicates

Hi all,

 

I have a duplicate ranking issue. At an overall level, it's fine, however bringing in multiple columns creates duplicate rankings.

 

As you can see overall is fine, but group 1 has multiple 12's. I want unique rankings for each category based on it's volume. This is my formula: 

Rank = RANKX (FILTER (ALL ('Table1'[SubCat]),'Table1'[SubCat] <> BLANK() && 'Table1'[SubCat] <> "UNTAGGED"),[Totalvols],,DESC)

I've gone to places like Chat GPT which ended up telling me to get help elsewhere. 
 
Thanks.

7 Replies

  • Anonymous - firstly you need to include all columns from your visual in the ranking, this is what is causing your duplication, secondly I would suggest putting the filtering on the visual and taking it out of the ranking. Please try the code below:

     

    RANKX (ALLSELECTED('Table1'[SubCat], 'Table1'[Group]),[Totalvols],,DESC)

     

    If you find you still need the filtering, you can use the ALLSELECTED from my code, rather than the ALL from yours. 

     

    If this works, please accept this as the solution, if it does not, please supply some sample data for me to test. 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Sadly this is now ranking across all columns rather ranking for each individual column. I will try and provide sample data, but need to remove sensitive data first. 

       

      • mark_endicott's avatar
        mark_endicott
        Super User

        Anonymous - Sorry for the late response, I have been travelling a lot the last 2 days.

         

        I misread your challenge the first time, so my code was not going to work for you, sorry about that. 

         

        Having seen your screenshot, I can see why you have duplicate rankings. In group 1 you have 3 [Totalvols] of 89, 3 [Totalvols] of 117 and 3 visible 153's.

         

        These will all be producing duplicate ranks because they have the same value. If you want them to have different ranks, you need to provide another measure to break the ties.  

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Anonymous 

    First, create a Index in PowerQuery.

    Then click Apply&Close.
    Create a calculated column, and treat the Index you just created as a secondary sort, which must be uniquely identified and cannot have duplicate values. Otherwise, when your sort has the same value and the sub-sort value is the same, the rank will be the same. Here is my preview:

    Column = ROWNUMBER(ORDERBY('Table'[Totalvols],DESC,'Table'[Index],ASC))

     

    How to Get Your Question Answered Quickly 

    Best Regards

    Yongkang Hua

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • mark_endicott's avatar
      mark_endicott
      Super User

      Anonymous - I dont agree with this solution, though you are correct, it removes the duplicates. In terms of ranking, the duplicates are legitamately there.

       

      If a business user was to ask what the criteria was for separating the items that have 100 as a total volume, the answer would be "random chance" and that's not acceptable. It could lead to a poor decision being made by an organisation.