Forum Discussion
Sorting by multiple columns
- 7 years ago
You may try using ISONORAFTER Function to add a measure.
Measure = VAR t = SUMMARIZE ( ALLSELECTED ( Table1 ), Table1[Employee], Table1[Training], Table1[Date] ) RETURN COUNTROWS ( FILTER ( t, ISONORAFTER ( Table1[Employee], SELECTEDVALUE ( Table1[Employee] ), DESC, Table1[Training], SELECTEDVALUE ( Table1[Training] ), ASC, Table1[Date], SELECTEDVALUE ( Table1[Date] ), DESC ) ) )
You may try using ISONORAFTER Function to add a measure.
Measure =
VAR t =
SUMMARIZE (
ALLSELECTED ( Table1 ),
Table1[Employee],
Table1[Training],
Table1[Date]
)
RETURN
COUNTROWS (
FILTER (
t,
ISONORAFTER (
Table1[Employee], SELECTEDVALUE ( Table1[Employee] ), DESC,
Table1[Training], SELECTEDVALUE ( Table1[Training] ), ASC,
Table1[Date], SELECTEDVALUE ( Table1[Date] ), DESC
)
)
)
- anandav7 years agoSkilled Sharer
Hi v-chuncz-msft,
Thank you for the prompt reply. That works perfectly! :manhappy:
I was also able to achieve this by adding an Index column in the Power Query as well. But good to learn how to do it in DAX.
Just wondering:
So any data re-ordering / sorting done in PowerQuery is really of no use in any of the visuals.
Do you think this is a bug or by design?
If by design, I am not sure what use it is to sort something in PowerQuery and the sort is not maintained in visuals?
I will mark your answer as solution shortly but just waiting to get some thoughts on the above questions from you ro anyone who might shed some light.
- usman23387 years agoFrequent Visitor
I guess Using Index as you mentioned is the easiest. Just sort in power query and then create Index column
- v-chuncz-msft7 years agoCommunity Support
- anandav7 years agoSkilled Sharer
Voted for the idea here:
Now it is wait and see time.
- usman23387 years agoFrequent Visitor
Would appreciate if you could explain what is going on in the code. I've used this and it gives me the correct sorting behaviour but i don't understand the workings of the code. Thanks