Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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

@RAHEEL

 

See the pic below

I added one row with same experience and age

 

54.png

 


Regards
Zubair

Please try my custom visuals

Perfectooooo 🙂 this worked for me 🙂 thanks 🙂

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.