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] )
Anonymous
4 years agoNot applicable
Hello ebecerra ,
We can achieve it by a little different method. By adding two rank functions in an if-else clause. The issue is RANKX function couldn't accept variables in the ORDER attribute.
You can find the solution and measure formula below :
Thanks,
Neel