Forum Discussion
Change sort order based on measure selection
Hi,
I am not sure how to change the sort order based a measure selection.
I have a matrix table showing measure based on the selection from a slicer. My problem is with the sorting order based on selection.
Example :
Slicer Matrix Table
ER Accounts Total
CM a 100
TC b 40
TR c 90
When I select "ER" or "TR" from slicer, i want the table to sort the measure in Descending order and on "CM" and "TC" selection, the sorting order should change to Ascending order
Please advise how can i achieve it.
Thanks
Shinu
9 Replies
- Shinu1
Helper II
Different measures are looked with different perspective.
Example: The Cost line items are all in negative and hence the highest negative amount needs to pulled at the top in matrix table and viceversa for Reveue/Profit.
Hope I'm clear
Thanks
Shinu
- mhossain
Solution Sage
Hi Shinu1
Try below, I don't know your table names, "tbl_Processed_Rawdata" you can try "ALL" in below dax, basically we want to clear the slicer selection while calculating the rank, ranks should be based on all the KPIs, so adjust below measures or provide me the snapshot of sample data, hope this makes sense.
Rank Measure =
VAR selected =
SELECTEDVALUE ( tbl_KPI[KPI] )
VAR rankER = RANKX(All(tbl_Processed_Rawdata),[ExternalRevenue],,DESC)
VAR rankCM = RANKX(All(tbl_Processed_Rawdata),[Contribution Margin],,ASC)
VAR rankTC = RANKX(All(tbl_Processed_Rawdata),[Total Cost],,ASC)
VAR rankTR = RANKX(All(tbl_Processed_Rawdata),[Total Revenue],,DESC)
RETURN
SWITCH ( selected, "ER", rankER, "CM", rankCM, "TC", rankTC, "TR", rankTR )