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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Dynamic ranking using RANKX

I'm trying to rank companies based on different metrics and in this specific case I want to use card visualizations to show ranking of each measure only for XPO Logistics. I've already looked up a few related topics here and on google but still cannot figure out what is wrong with my measure.

 

The problem arises when I filter by market. Without any box checked, the measure is working as intended but when I click, for example, on Memphis, XPO is ranked 10th while it's actually 9th. Any idea what can be changed to make it accurate?

 

I'm attaching the file for review

 

Link https://dir.nu/615206444436e

6 REPLIES 6
Anonymous
Not applicable

bump. Still struggling with this 

Jihwan_Kim
Super User
Super User

Hi,

the file is deleted, and I could not find any file.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Hmm how about this one?

 

https://dir.nu/615206444436e

Hi,

I am not sure if I understood your question correctly, but please try the below measure.

 

Unsafe Driving Rank =
RANKX (
FILTER ( ALLSELECTED ( Data ), [Unsafe Driving Measure] <> 0 ),
[Unsafe Driving Measure],
,
ASC,
DENSE
)

 

In my opinion, if the order is ASC, then the companies that have zero value of Sum of unsafe driving get ranking number one. Selecting an option of Dense or Skip is based on the business requirement.

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Jihwan,

 

0 means that the company has had 0 incidents of unsafe driving and should be ranked 1st so we should not be omitting the 0. The formula your provide seems to be doing the same thing as mine and doesn't rank correctly once we apply the market filter

 

 

Anonymous
Not applicable

Hi @Anonymous,

Did these '0' records real include in your tables? If they mean your table does not include these types of records, Dax formulas can't directly calculate with these not existed records.
For this scenario, you may need to add a parameter table with all companies to force expand and calculate on them.
Regards,
Xiaoxin Sheng

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.