Forum Discussion
RANKX woes
Need some help here. I have this formula that I am using to rank each location in my locations dimension table. RankX would well using this formula, but when I use the arrow buttons to go from location to subregion to region, the rank no longer works as expected.
Here's my formula.
Hi,
According to your description, i create a table to test:
Then i create a measure to calculate each level's rank:
Rank = IF ( ISINSCOPE ( Pupolation[Address] ), RANKX ( CALCULATETABLE(DISTINCT(Pupolation[Address]),ALLSELECTED(Pupolation)), CALCULATE ( SUM ( Pupolation[Population] ) ), , ASC ), IF ( ISINSCOPE ( Pupolation[Location] ), RANKX ( CALCULATETABLE(DISTINCT(Pupolation[Location]),ALLSELECTED(Pupolation)), CALCULATE ( SUM ( Pupolation[Population] ) ), , ASC ), RANKX ( CALCULATETABLE(DISTINCT(Pupolation[Country]),ALLSELECTED(Pupolation)), CALCULATE ( SUM ( Pupolation[Population] ) ), , ASC ) ) )And it shows:
Hope this helps.
Best Regards,
Giotto Zhi
2 Replies
- v-gizhi-msft
Community Support
Hi,
According to your description, i create a table to test:
Then i create a measure to calculate each level's rank:
Rank = IF ( ISINSCOPE ( Pupolation[Address] ), RANKX ( CALCULATETABLE(DISTINCT(Pupolation[Address]),ALLSELECTED(Pupolation)), CALCULATE ( SUM ( Pupolation[Population] ) ), , ASC ), IF ( ISINSCOPE ( Pupolation[Location] ), RANKX ( CALCULATETABLE(DISTINCT(Pupolation[Location]),ALLSELECTED(Pupolation)), CALCULATE ( SUM ( Pupolation[Population] ) ), , ASC ), RANKX ( CALCULATETABLE(DISTINCT(Pupolation[Country]),ALLSELECTED(Pupolation)), CALCULATE ( SUM ( Pupolation[Population] ) ), , ASC ) ) )And it shows:
Hope this helps.
Best Regards,
Giotto Zhi
- amitchandak
Super User
I think the above solution should solve your problem, These three Rank articles can help you more.
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-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale