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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
sizi
Helper II
Helper II

Dax to define Rank based on 2 conditions

Hello All,

 

I have a requirment where i need to rank the employee based on Total tasks and min days taken. 

 Below is the data :

EmployeeTotal TaskMin Days Taken
John3220
Bethany2032
Johnny2520
Claire3015

 

The result is as below :

EmployeeTotal TaskMin Days TakenRank
John32202
Bethany20324
Johnny25203
Claire30151

The rank should be based on below conditions:

1. Check for Highest value under total task column

2.Check for least/min number of days taken under Min Days Taken column

 

The ratio task :days taken needs to be considered and not average.

 

Based on these condition rank shall be defined as above. If condition is true 1st rank and so on for all records in the table giving rank in sequence based on the condition defined.

 

Kindly help. 

Thanks,

1 ACCEPTED SOLUTION

@sizi 

Try this measure:

Rank Emp = 
IF(
    ISINSCOPE( Table29[Employee] ),
    RANKX( 
        ALLSELECTED( Table29[Employee] ) ,
        DIVIDE(
            CALCULATE( SUM( Table29[Total Task] ) ),
            CALCULATE( SUM( Table29[Min Days Taken] ) )
        )
    )
)

Fowmy_0-1705751166356.png

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

13 REPLIES 13
ThxAlot
Super User
Super User

.



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



second dax giving error wheeras ratio rank dax ranking lowest as 1 and highest as 4

its giving me lowest employee has highest rank . 

Bibiano_Geraldo
Super User
Super User

Why John is first and Claire is second? Because the average show me Claire in the first position

Thanks for the highlighting it. It was by mistake. The result should be below : 

EmployeeTotal TaskMin Days TakenRank
John32202
Bethany20324
Johnny25203
Claire30151

 

However we wont consider average but ratio  task : min days taken. 

Try this:

  1.  Create a nem measure with the following code:
    Average = AVERAGEX(Data,DIVIDE(Data[Min Days Taken],Data[Total Task]))
  2. Create other measure with the following code:
    Rank = RANKX(ALLSELECTED(Data[Employee]),[Average],,ASC)
  3. Create a Matrix table and use employee for rows and the Rank measure for values

Bibiano_Geraldo_0-1705742954499.png

Note: Replace 'Data' with your table name

Its giving me same average for all the employees as 2.

 

Actual data is as below  and rank should be defined accordingly.

EmployeeTotal TaskMin Days TakenRank
John32201
Bethany20325
Johnny7207
Claire24354
Tiffany24323
Bobby17586
Jay28202

@sizi 

Try this measure:

Rank Emp = 
IF(
    ISINSCOPE( Table29[Employee] ),
    RANKX( 
        ALLSELECTED( Table29[Employee] ) ,
        DIVIDE(
            CALCULATE( SUM( Table29[Total Task] ) ),
            CALCULATE( SUM( Table29[Min Days Taken] ) )
        )
    )
)

Fowmy_0-1705751166356.png

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Perfect. It worked. Thanks so much.👍

@sizi 

Glad it works!
Please accept my answer as the solution so it will be beneficial for others with the same questions 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

something you did wrong, show me your measures to make sure they a correct. i just updated the table as you can see bellow

 

Bibiano_Geraldo_0-1705744492998.png

 

Hi, I have another scenario where in i need to get the average of 2 rank column and define the overall rank with low value as highest.

Below is the data:

EmployeeDemandRankSLARankBA Rank
    
claire423
Chris444
Rock264
Bella634.5
Harry714
Stefanie153

The result shall be :

EmployeeDemandRankSLARankAvg Demand+SLAOverall Rank
John232.51
claire4232
Chris4443
Rock2643
Bella634.54
Harry7143
Stefanie1532

AverageRank = RANKX( ALL('Table'[Employee]), [BA Rank], , ASC ) ,,

 

 

i tried multiple dax but this was close however it still skips the sequence of ranking 1-10.

Kindly help.

 

Thanks,

It worked. I did something wrong. However i want to exclude employee 134 from the table and ranking should be defined accordingly.

 

Currently the result is below :

 

EmployeeTotal TaskMin Days TakenRank
John32202
Bethany20326
Johnny7208
Claire24355
Tiffany24324
Bobby17587
Jay28203
1342 1

Could you help to filter out the employee and update the ranking accordingly?

 

Thanks. Appreciate your help. 👍

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors