Forum Discussion

SpanishEnjoyer's avatar
SpanishEnjoyer
New Member
1 year ago

Using function Rank or Rankx for grouped rankings

Hello,

I have two tables related to each other by ID. One table has information about dates when a equipment failed and how it did and the other table contains information about all equipments (id,category, room, building)  just like this:

Eq IDMonth yearFailure Mode
0012-2024-
0023-2024-

002

6-2024-
0048-2024-
0032-2024-

 

Eq IDCathegoryRoom Building
001Electrical10A
002Electrical11A
003Mechanical10A
004Mechanical12B

I already created a metric that counts how many times an equipment appears in table Failures:

 

Count_Failures = CALCULATE(COUNTROWS('Table Failures')
 
Also I used the function RANK to know the rankings of each equitment
 
Ranking  = RANK(DENSE,FILTER(ALL('Table Equipments'),'Table Equipments'[ID Eq]<>BLANK()),ORDERBY([Count_Failures],DESC))
 
However, I need to know for example, the ranking of equipment per cathegory or per room like the table below , it doesn´t matter if  it´s neccesary to created two new metrics. 
 
Eq IDCathegoryRoomTotal FailuresRank per CathegoryRank per Room
001Electrical10121
002Electrical11211
003Mechanical10111
004Mechanical12111

 

NOTE: I would like to keep using the metric Count_failures because it can changes over time instead of a calculated column in the table Equipments wich will have an static value.

 

 

3 Replies

  • Hi SpanishEnjoyer -Create a new measure that ranks the equipment based on the number of failures within its respective category

    Rank_Per_Category =
    RANKX(
    ALLSELECTED('Table Equipments'[ID Eq]),
    [Count_Failures],
    ,
    DESC,
    DENSE
    )

     

    create another measure for rank for each room as below:

    Rank_Per_Room =
    RANKX(
    ALLSELECTED('Table Equipments'[ID Eq]),
    [Count_Failures],
    ,
    DESC,
    DENSE
    )

     

    this way you can achieve, hope it works.

    • SpanishEnjoyer's avatar
      SpanishEnjoyer
      New Member

      Thanks for your answer,  but the new metrics works as the metric Ranking that is already created.  It doesn´t rank the equipment by cathegory or room.

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi SpanishEnjoyer ,

         

        I don't quite understand your grouping logic, if the room ordering 001 and 003 should be the same, they should both return 2.

         

        Please detail your needs and demonstrate the expected results.

         

        Best regards,
        Community Support Team_ Scott Chang