Forum Discussion
Sorting two date columns
In my data I have two date columns, one is RaisedOrder date and the other is DeliveryDate.
I've created a slicer (using the hierarchy slicer) for each of these columns by Year and Month name. Currently, the slicer is sorted by month name alphabetically, (e.g April at the top).
I would like to sort this by month number so that January is at the top and December at the bottom. And I'd like to do this for both slicers for RaisedOrder date and DeliveryDate.
Any ideas?
Thanks
afk
Hi V-lianl-msft , I solved it by bringing in the month number directly from the data source, along with the month name. I could then sort the month name by the month number and this looked to solve the issue.
Initially I'd created a month number column within Power BI, based off of the date, and then sort the month name by this column but this didn't work.
10 Replies
- amitchandakSuper User
Create a month Sort column and mark it as sort column
sort Month = format(date[date],"YYYYMM")
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin- bo_afkPost Patron
Hi amitchandak , thanks for your suggestion. But when I try to do this, it gives me the error message "this column can't be sorted by a column that is already sorted, directly or indirectly, by column".
I don't remember sorting any other columns by this...but is it possible for me to double-check this?
- amitchandakSuper User
Please make sure the sort column is not based on month-year column. Both of them can be based on the same base column-like Date.
- apentyalaHelper II
Create a Date table and sort month name using month number. maybe it will useful
https://www.youtube.com/watch?v=cnH6oMhWKOE
Regards,