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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
paguy215
Helper III
Helper III

RankX issue getting close but still some ties that shouldn't be there

I am trying to rank agents by sales based on selected date range

 

I have this rank formula

 

RANKX(ALLSELECTED('Agent List'),CALCULATE(sum(Query1[RevenueSum])),,,Skip)
 
Agent List is a table of unique sales IDs, Query1 is the sales data, which lists the total sales for each agent on each day
 
This is really close, and almost all align perfectly well, however I have few cases where the RevenueSums are different but the ranking is the same.  Also, when I change the date range the more cases like this I get ...none of these duplicate rankings are true ties
 
paguy215_0-1737746068164.png

 

2 REPLIES 2
DataNinja777
Super User
Super User

Hi @paguy215 ,

 

The issue you're facing with duplicate rankings, even when the RevenueSum values are different, is likely due to floating-point precision or the lack of a unique tiebreaker. To resolve this, you can enhance your ranking formula by adding a tiebreaker that ensures uniqueness. This can be achieved by incorporating a unique identifier for each agent, such as their Agent ID, into the ranking logic. Here's the updated formula:

Rank =
RANKX(
    ALLSELECTED('Agent List'),
    CALCULATE(SUM(Query1[RevenueSum])) + DIVIDE(UNIQUEVALUE('Agent List'[Agent ID]), 1000000),
    ,
    ASC, 
    Skip
)

In this formula, the primary ranking is still based on the RevenueSum, but by adding the agent's unique ID (scaled down to a negligible value), you introduce a secondary criterion to break ties. The division ensures that the ID doesn't significantly alter the primary ranking while still differentiating agents with similar RevenueSum values. If the issue persists, you can also round the RevenueSum values in the formula to ensure consistent precision, as shown below:

Rank =
RANKX(
    ALLSELECTED('Agent List'),
    ROUND(CALCULATE(SUM(Query1[RevenueSum])), 2) + DIVIDE(UNIQUEVALUE('Agent List'[Agent ID]), 1000000),
    ,
    ASC, 
    Skip
)

This ensures that any minor inconsistencies caused by floating-point precision are eliminated. These changes should resolve your issue and ensure accurate ranking across all scenarios, including when filtering by a date range. Let me know if you encounter any further challenges.

 

Best regards,

Thanks for the help...however, I still can't get it to work.   UNIQUEVALUE doesn't appear to be an option to use in my version.   I tried it with DISTINCT and I get an error saying "multiple values were supplied when a single value was expected"

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors
Top Kudoed Authors