Forum Discussion
Sorting DAX date table
I currently have a date table I use for my table matrix. Im trying to show 2020 and 2021 data in the matrix, but want it sorted desending showing jan 4 2021 first and going down. I cant seem to get it that way since I have 3 date columns in the matrix Year, Month and day. No matter waht way I sort I cannot get it this way. I tired sorting by all of the 3, but doesnt work since the year is the top. Only works when Im doing 1 month.
Thanks
10 Replies
- vanessafvgCommunity Champion
why dont you create a date column from the 3 columns?
- amitchandakSuper User
Anonymous , Where are you showing date , If you showing on column(pivot) you need to have sort column to change it to descending.
Create date if you do not have
Date = date([Year],[month], [day])
Date1 = date([Year],[month], [day])
Date Sort = rankx(all(Table), [Date],,desc)
Sort Date1 on date sort and use.
Refer to my video on this: https://www.youtube.com/watch?v=KK1zu4MBb-c
- AnonymousNot applicable
Hi Anonymous,
Have you tried to create a calculated table with custom sorting orders and link to your raw table fields?
BTW, for multiple column sorting, you can try to use ISONORAFTER function:
Sorting by multiple columns
Regards,Xiaoxin Sheng
- AnonymousNot applicable
HI Anonymous.,
Did these suggestions help with your requirement? If not, please provide more detailed information and some dummy data to help us clarify your scenario and test to coding formula.
How to Get Your Question Answered Quickly
Regards.
Xiaoxin Sheng
- AnonymousNot applicable
Sorry I have been OOO. I was able to just use the main date and sort it that way instead of by month, day , year
- AnonymousNot applicable
HI Anonymous,
I'm not so clear about your descriptions, can you please share some dummy data with the expected result (the way similar as the above blog link mention) to help us clarify your scenario and requirements?
BTW, if you are working with situations that similar as creating 'sorting order' on a calendar based on fiscal date, you can take a look at the following blog:
DAX 101: Sorting months in fiscal calendars
Regards,
Xiaoxin Sheng