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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
erihsehc
Helper III
Helper III

ranking error

ranking issue.JPGranking issue2.JPG

rank customer = RANKX(ALLSELECTED(Table1),CALCULATE(SUM(Table1[sales]),ALLEXCEPT(Table1,Table1[Customer],Table1[factory])))

so strange that A and B are at same rank, what is the problem here? thanks

1 ACCEPTED SOLUTION
Dog
Responsive Resident
Responsive Resident

Hi, 

 

Looks like the Ranking is correct on that screen shot as it's performing the ranking at customer level for each factory.
you'd need to adjust the RANKX statement to perform the ranking at factory level to change the values.

I do something similar and I check to see what's filtered and amend the measure accordingly.

 

 

try this instead. 

 

RankCustomer =
IF(HASONEVALUE(Table1[factory]),
RANKX(ALLSELECTED(Table1), CALCULATE(sum(Table1[sales]), ALLEXCEPT(Table,Table1[Customer], Table1[factory]))) ,
RANKX(ALLSELECTED(Sheet1), CALCULATE(sum(Sheet1[sales]), ALLEXCEPT(Sheet1,Sheet1[Customer])), ,DESC,Dense) )

View solution in original post

8 REPLIES 8
Dog
Responsive Resident
Responsive Resident

Hi @erihsehc,

 

I assume it's due to the Factory column included in your ALLEXCEPT function, this would work if you were displaying the column I think. 

 

using the following works for me. (using my own column and table names)

 

RankCustomer = RANKX(ALLSELECTED(Sheet1), CALCULATE(sum(Sheet1[sales]), ALLEXCEPT(Sheet1,Sheet1[Customer])), ,DESC,Dense)

 

Dog

Thanks @Dog. I have tried the formula, the ranking is correct but the factory slicer is not working, the ranking remain unchanged when I select different country. how to make the ranking correct and also the slicer works? thanks

rank customer = RANKX(ALLSELECTED(Table1),CALCULATE(SUM(Table1[sales]),ALLEXCEPT(Table1,Table1[Customer])),,DESC,Dense)

 

ranking issue3.JPG

Hi @erihsehc,

 

Based on my test, the formula below should work in your scenario. Smiley Happy

rank customer = 
RANKX (
    ALLSELECTED ( Table1 ),
    CALCULATE ( SUM ( Table1[sales] ), ALLEXCEPT ( Table1, Table1[Customer], Table1[factory] ) ),
    ,
    DESC,
    DENSE
)

r1.PNG

 

Regards

thanks @v-ljerr-msft. The ranking is correct for factory, but if you select all factories and countries, the ranking is strange per my top post. Smiley Happy

Hi @erihsehc,

 

My mistake. Smiley LOL

 

Try the formula below. It should work. 

rank customer = 
RANKX (
    ALLSELECTED ( Table1[Customer]),
    CALCULATE ( SUM ( Table1[sales] ), ALLEXCEPT ( Table1, Table1[Customer], Table1[factory] ) ),
    ,
    DESC,
    DENSE
)

r2.PNGr3.PNG

 

Regards

thanks @v-ljerr-msft, it is what I want.

 

Out of curiosity, I added the factory field to the table, the ranking seems strange again, not sure the logic of this ranking. ranking issue6.JPG

Dog
Responsive Resident
Responsive Resident

Hi, 

 

Looks like the Ranking is correct on that screen shot as it's performing the ranking at customer level for each factory.
you'd need to adjust the RANKX statement to perform the ranking at factory level to change the values.

I do something similar and I check to see what's filtered and amend the measure accordingly.

 

 

try this instead. 

 

RankCustomer =
IF(HASONEVALUE(Table1[factory]),
RANKX(ALLSELECTED(Table1), CALCULATE(sum(Table1[sales]), ALLEXCEPT(Table,Table1[Customer], Table1[factory]))) ,
RANKX(ALLSELECTED(Sheet1), CALCULATE(sum(Sheet1[sales]), ALLEXCEPT(Sheet1,Sheet1[Customer])), ,DESC,Dense) )

Thanks @Dog, I used this dax,, the ranking result is reasonable when twisting field

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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