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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
chudson
Helper IV
Helper IV

Using RANKX or DAX measure to creating a ranking based on 2 calculated measures

Hi,

 

I'm hoping someone can help me here with ranking a report visual table.  Below is an example of the data I'm showing as a table visual in a report and I have a rankx function that ranks the districts by % to quota but I want a 2nd ranking measure in here to rank the districts by their QTD Quota # that would break a tie if the % to quota were the same (in this case a lot of the districts with 0 % to quota).

So instead of ranking all Districts in my example as 12, the rank would look at 0% of % to Quota and thank rank by the QTD Quota #.

 

My Rank Column is calculated measure = 

RANKX(ALLSELECTED(DimSalesAgent[DISTRICT]),[% to Quota],,DESC)
 
Also, to note my QTD, QTD Quota, % to Quota are all calculated measures as well.

 

 

RANKDISTRICTQTD SalesQTD Quota% to Quota
1District 1$55,582$50,770109%
2District 2$347,563$187,500185%
3District 3$32,206$87,84437%
4District 4$194,298$223,77987%
5District 5$514,625$490,000105%
6District 6$979,158$1,056,84393%
7District 7$186,375$264,32771%
8District 8$724,728$847,00086%
9District 9$57,059$140,27341%
10District 10$610,496$750,00181%
11District 11$414,430$547,20076%
12District 12$0$10,6130%
12District 13$0$140,0000%
12District 14$0$116,7520%
12District 15$5,400$00%
12District 16$0$119,8340%
12District 17$25,370$00%
12District 18$0$00%
12District 19$0$75,0000%
12District 20$0$186,6780%

 

Thanks!

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi, @chudson 

You could refer to this same post:

https://community.powerbi.com/t5/Desktop/How-to-Rank-a-list-based-on-2-values-double-rankX/td-p/4400...

 

And for your case, just use this formula:

Final Rank = 
RANKX (
    ALLSELECTED(DimSalesAgent[DISTRICT]),
    RANKX(ALLSELECTED(DimSalesAgent[DISTRICT]),[% to Quota],,DESC)
        + DIVIDE (
            RANKX(ALLSELECTED(DimSalesAgent[DISTRICT]),[QTD Quota],,DESC),
            ( COUNTROWS ( ALLSELECTED(DimSalesAgent[DISTRICT]) ) + 1 )
        )
,,ASC)

Result:

2.JPG

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi, @chudson 

You could refer to this same post:

https://community.powerbi.com/t5/Desktop/How-to-Rank-a-list-based-on-2-values-double-rankX/td-p/4400...

 

And for your case, just use this formula:

Final Rank = 
RANKX (
    ALLSELECTED(DimSalesAgent[DISTRICT]),
    RANKX(ALLSELECTED(DimSalesAgent[DISTRICT]),[% to Quota],,DESC)
        + DIVIDE (
            RANKX(ALLSELECTED(DimSalesAgent[DISTRICT]),[QTD Quota],,DESC),
            ( COUNTROWS ( ALLSELECTED(DimSalesAgent[DISTRICT]) ) + 1 )
        )
,,ASC)

Result:

2.JPG

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-lili6-msft 

Thanks! that formula helps so much!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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