Forum Discussion
RANKX not working as expected
Hi All,
I have a measure to rank staffs based on sales as follows :
https://drive.google.com/file/d/1R2HPsre1Jw56frrbuuwEG9TH2r72h3sn/view?usp=sharing
Thanks in advance
Hi Jos13 ,
The Rank is working correctly, the users with no sales are ranked last, makes sense to me. what you need to do is exclude them from the rank function
like so
Rank_Sales = if(sum('Table'[Sales]) <> BLANK(), RANKX(ALLSELECTED('Table'[Staff]),[Sales_],,DESC), BLANK())Hope this Helps
Richard
Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!
4 Replies
- richbenmintz
Resident Rockstar
Hi Jos13 ,
The Rank is working correctly, the users with no sales are ranked last, makes sense to me. what you need to do is exclude them from the rank function
like so
Rank_Sales = if(sum('Table'[Sales]) <> BLANK(), RANKX(ALLSELECTED('Table'[Staff]),[Sales_],,DESC), BLANK())Hope this Helps
Richard
Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!- Jos13
Helper III
Thank you richbenmintz . That worked for me.
- Greg_Deckler
Community Champion
Jos13 - See this article, it may help. https://community.powerbi.com/t5/Quick-Measures-Gallery/To-Bleep-with-RANKX/m-p/1042520#M452
- amitchandak
Super User
Jos13 ,
Try mutiple columns, example
City and ID Rank = RANKX(all(Geography[City],Geography[City Id]),[Sales])
City and ID Rank = RANKX(allselected(Geography[City],Geography[City Id]),[Sales])
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
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/367415