cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RAHEEL
Helper I
Helper I

Rank a column but in case of same values consider another column too for ranking

Hi All, 

I need help to rank below dataset using dax function in power bi.

I have resources and I want to assign them unique numbers based on their experience, but if more than 1 resource has the same experience then also consider age column and who is elder get the smaller number (i.e. higher rank)

e.g. R1, R3 and R5 all have 11 yrs of exp and will get a normal rank of 1 but I want them to assign 3,1 & 2 ranks respectively as per below data based on their exp and age.

I also donot want to skip any of the sequence in rank numbers.

Kindly assist.

Also, I am not sure if there is anyother of doing the same thing other than Rank function.Last column in RED i.e. RankingColumn is the desired output column. Much appreciated. Thanks

resourceExpAgeRankingColumn
R111403
R210384
R311421
R46284
R511412
R65265

 

 

Regards,

Raheel

 

2 ACCEPTED SOLUTIONS

Hi @RAHEEL

 

In that case

 

First Add an Index Column to your Table Using QueryEditor/Power Query

 

53.png

 

Now you can use this formula

 

RANK=
RANKX (
    Table1,
    Table1[Exp]
        + Table1[Age] / 100
        + Table1[Index] / 1000,
    ,
    DESC,
    DENSE
)
Regards
Zubair

Please try my custom visuals


View solution in original post

@RAHEEL

 

See the pic below

I added one row with same experience and age

 

54.png

 

Regards
Zubair

Please try my custom visuals


View solution in original post

6 REPLIES 6
Zubair_Muhammad
Community Champion
Community Champion

Hi @RAHEEL

 

Try this technique

 

Add an Assistant Calculated Column

 

Assistant Column =
Table1[Exp]
    + Table1[Age] / 100

Now you can Rank using this Column

 

RANK=
RANKX ( Table1, Table1[Assistant Column],, DESC, DENSE )

33.png

Regards
Zubair

Please try my custom visuals


@RAHEEL

 

Infact no need for the Assistant Column.

 

This Calculated Column should suffice

 

RANK =
RANKX ( Table1, Table1[Exp] + Table1[Age] / 100,, DESC, DENSE )

 

 

Regards
Zubair

Please try my custom visuals


Perfect....this worked...BUT there is still one issue....where both the age and exp are same it is resulting in the same Rank...any idea how to manage this? 

Your time is much appreciated:)

Hi @RAHEEL

 

In that case

 

First Add an Index Column to your Table Using QueryEditor/Power Query

 

53.png

 

Now you can use this formula

 

RANK=
RANKX (
    Table1,
    Table1[Exp]
        + Table1[Age] / 100
        + Table1[Index] / 1000,
    ,
    DESC,
    DENSE
)
Regards
Zubair

Please try my custom visuals


View solution in original post

@RAHEEL

 

See the pic below

I added one row with same experience and age

 

54.png

 

Regards
Zubair

Please try my custom visuals


View solution in original post

Perfectooooo 🙂 this worked for me 🙂 thanks 🙂

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!