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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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