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
AUaero
Responsive Resident
Responsive Resident

RANKX inconsistent results

Hi,
I am have a measure that ranks sales people by a defined KPI ($ Rolling GM per Ton).

# OSR GM per Ton Rank = 
RANKX(
    FILTER(
        ALL(OSRs[OSR_NAME]),
        NOT(ISBLANK(OSRs[OSR_NAME]))
    ),
    Sales[$ Rolling GM per Ton],
    ,
    DESC,
    DENSE
)

 $ Rolling GM per Ton is a measure that calculates GM per ton for the previous year period.

$ Rolling GM per Ton = 
CALCULATE(
    Sales[$ GM per Ton],
    DATESBETWEEN(
        'Calendar'[DATE_DESC],
        NEXTDAY(SAMEPERIODLASTYEAR(LASTDATE('Calendar'[DATE_DESC]))),
        LASTDATE('Calendar'[DATE_DESC])
    )
)

I have created a table visual consisting of the sales person name, $ Rolling GM per Ton, and # OSR GM per Ton Rank.  The table has a visual level relative date filter setting 'Calendar'[DATE_DESC] to show results in the last 365 days.  This visual correctly ranks each sales person.

I have created a card visual that displays # OSR GM per Ton Rank.  When I select a row for a specific sales person in my table visual, I would expect the card visual to display the same value for #OSR GM per Ton Rank that is displayed in the table.  However, this is not the case.  The card visual generally shows one rank lower than what is displayed in the table.  For example, if the rank in the table is 2, the card visual displays 3.  This is not consistent, though.  For some sales people, the rank displayed is the same in the card and in the table.

I feel like there is something I'm missing in the filter context being applied to the # OSR GM per Ton Rank measure when it is displayed outside the table visual, but I can't figure it out.

Any ideas?

Thanks!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Please try to move  NOT(ISBLANK(OSRs[OSR_NAME]) filter to your calculation of  and try

# OSR GM per Ton Rank = 
RANKX(
    FILTER(
        ALL(OSRs[OSR_NAME]),
        NOT(ISBLANK(OSRs[OSR_NAME]))
    ),
    Sales[$ Rolling GM per Ton],
    ,
    DESC,
    DENSE
)

 

Also refer:

https://community.powerbi.com/t5/Desktop/RANKX-woes/m-p/912940#M437593

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale

  

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Could you share a simple dataset and show the expected result?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

Please try to move  NOT(ISBLANK(OSRs[OSR_NAME]) filter to your calculation of  and try

# OSR GM per Ton Rank = 
RANKX(
    FILTER(
        ALL(OSRs[OSR_NAME]),
        NOT(ISBLANK(OSRs[OSR_NAME]))
    ),
    Sales[$ Rolling GM per Ton],
    ,
    DESC,
    DENSE
)

 

Also refer:

https://community.powerbi.com/t5/Desktop/RANKX-woes/m-p/912940#M437593

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale

  

Greg_Deckler
Super User
Super User

Can you apply the same filter that is on your table to your Card?

 

Man, I would hate to get into yet another RANKX weirdness problem!! See this beauty! https://community.powerbi.com/t5/Desktop/Rank-by-measure-in-Direct-Query/m-p/953543#M456870


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.