Forum Discussion

kirbynguyen's avatar
kirbynguyen
Icon for Helper II rankHelper II
5 years ago
Solved

Ranking Per Row in a Matrix

Hello,

 

I have data that when put in a Matrix looks like this (keep in mind the data isn't just one row per value, there are multiple rows per combination, so each value in each cell is an aggregation):

 Apple   Banana   Celery   Donuts   Earth   Fork
A113218254130
B24834282149
C311032112225
D153148252028
E474419213738
F324330353617

 

What I want is to rank each value by row from highest to lowest, so the matrix i would like to have would be:

 Apple   Banana   Celery   Donuts   Earth   Fork
A625413
B462351
C261543
D621453
E126543
F415326

 

Data would look something like this:

Date    Name    Category    Value
1/1/2021AApple10
1/1/2021ABanana20
1/1/2021ACelery9
1/1/2021ADonuts20
1/1/2021AEarth35
1/1/2021AFork22
1/1/2021AApple1
1/2/2021AApple0

So, the values in the matrix are aggregations of the rows. The date doesn't matter in this context.

 

Please help. Thanks in advance!

  • kirbynguyen 

    You can use the following measure to get the desired ranking.

    Ranking = 
    IF( 
        HASONEVALUE(Table2[Category]) && HASONEVALUE(Table2[Name]),
        RANKX(
            ALLSELECTED(Table2[Category]),
            CALCULATE(SUM(Table2[Value]))
        )
    )
    

     

     

1 Reply

  • kirbynguyen 

    You can use the following measure to get the desired ranking.

    Ranking = 
    IF( 
        HASONEVALUE(Table2[Category]) && HASONEVALUE(Table2[Name]),
        RANKX(
            ALLSELECTED(Table2[Category]),
            CALCULATE(SUM(Table2[Value]))
        )
    )