Forum Discussion
M_Aird
8 years agoFrequent Visitor
RANKX exclude from rank, but include in table
Hi all, I have written the following RANKX DAX formula to rank States by current month value. The resulting table is below: State ranking (asc) = RANKX(ALLSELECTED('Current_month_labourforce'),c...
- 8 years ago
Hi M_Aird
Here's an idea that should work without changing your existing tables:
- Change your rank measure to this (updated slightly to rank over the State table as well as return blank result for Australia):
State ranking (asc) = IF ( SELECTEDVALUE ( State[State and territory] ) <> "Australia", RANKX ( CALCULATETABLE ( ALLSELECTED ( State ), State[State and territory] <> "Australia" ), CALCULATE ( SUM ( Current_month_labourforce[Current month value] ) ), , ASC ) ) - Add a "dummy" measure to rank the final table, which always gives Australia the highest possible rank:
R = IF ( SELECTEDVALUE ( State[State and territory] ) = "Australia", COUNTROWS ( ALLSELECTED ( State ) ), [State ranking (asc)] ) - Create a table containing R, State ranking (asc), State and territory and Current month value
- Sort by R
- Reduce the width of the R column heading until it is invisible.
- Result looks like this:
Well that's one method anyway. You could also add a special flag to the State table to flag Australia as being excluded from the ranking.
Cheers,
Owen :)
- Change your rank measure to this (updated slightly to rank over the State table as well as return blank result for Australia):
OwenAuger
Super User
8 years agoHi M_Aird
Here's an idea that should work without changing your existing tables:
- Change your rank measure to this (updated slightly to rank over the State table as well as return blank result for Australia):
State ranking (asc) = IF ( SELECTEDVALUE ( State[State and territory] ) <> "Australia", RANKX ( CALCULATETABLE ( ALLSELECTED ( State ), State[State and territory] <> "Australia" ), CALCULATE ( SUM ( Current_month_labourforce[Current month value] ) ), , ASC ) ) - Add a "dummy" measure to rank the final table, which always gives Australia the highest possible rank:
R = IF ( SELECTEDVALUE ( State[State and territory] ) = "Australia", COUNTROWS ( ALLSELECTED ( State ) ), [State ranking (asc)] ) - Create a table containing R, State ranking (asc), State and territory and Current month value
- Sort by R
- Reduce the width of the R column heading until it is invisible.
- Result looks like this:
Well that's one method anyway. You could also add a special flag to the State table to flag Australia as being excluded from the ranking.
Cheers,
Owen :)