Forum Discussion
ebecerra
4 years agoMicrosoft Employee
Using a variable to determine sort order inside Rankx
I'm using a slicer to select a "Sort type" for a visualization I have. Depending on what value is selected, I am planning to use that as the sort option for a RANKX function I have. For some reason w...
- 4 years ago
Another option might be to flip the sign of the measure depending on Top/Bottom.
VariableRank = VAR Sgn = IF ( SELECTEDVALUE ( 'Top or Bottom'[Option] ) = "Top", 1, -1 ) RETURN RANKX ( ALLSELECTED ( MyTable[pageTitle] ), Sgn * [Total PageViews] )
AlexisOlson
4 years agoSuper User
Another option might be to flip the sign of the measure depending on Top/Bottom.
VariableRank =
VAR Sgn = IF ( SELECTEDVALUE ( 'Top or Bottom'[Option] ) = "Top", 1, -1 )
RETURN
RANKX ( ALLSELECTED ( MyTable[pageTitle] ), Sgn * [Total PageViews] )ebecerra
4 years agoMicrosoft Employee
Sweet! I liked this solution as it is simple enough to understand and for my particular scenario. Thanks a lot to everyone else for their soultions!