Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
bo_afk
Post Patron
Post Patron

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

1 ACCEPTED SOLUTION

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.

View solution in original post

10 REPLIES 10
apentyala
Helper II
Helper II

Create a Date table and sort month name using month number. maybe it will useful

 

https://www.youtube.com/watch?v=cnH6oMhWKOE

 

Regards,

 

amitchandak
Super User
Super User

Create a month Sort column and mark it as sort column

sort Month = format(date[date],"YYYYMM")

Sort_by_column.png

 

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

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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?

 

 

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.

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak , can you go through the steps again please? It doesn't seem to have worked for me.

 

I have the following columns:

RaisedDateRaisedYearRaisedMonthDeliveryDateDeliveryYearDeliveryMonthQuantity
2020-01-032020January2020-03-142020March250
2020-01-062020January2020-05-052020May100

 

When I create a hierarchy slicer for DeliveryYear and Month, I get the following.

DateSlicer.JPG

Hi @bo_afk ,

 

There is a visual called "hierarchy slicer" in marketplace. Using this visual and applying the date hierarchy provided by powerbi can meet your needs.

slicer_sort_monthname.PNG

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @V-lianl-msft , thanks for your feedback. Initially I used this slicer but it was adding in extra years and months that didn't exist in my data so I was unable to use it. 

year slicer.JPG

Hi @bo_afk ,

 

Is this problem sloved?
If not, please let me know.

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

Hi @bo_afk ,

 

You need to sort "DeliveryMonth" by "DeliveryDate"

sort_monthname.PNG

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.