Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Month sorting within slicer

Hi everyone! I encountered a sorting problem, which is slightly different from the ones I found solved.

I have a custom table with Month list in a correct order:

When I use this column as a slicer, months are sorted in an alphabetic order: 

Is it possible to list them from Jan to Dec? I have seen a couple of solutions, using ranking or custom sorting, but I can't find a way to add this type of column to my month table. Any help would be valuable. Thanks in advance!

  • Hi Anonymous 

     

    You need a sort column, so Jan = 1, Feb = 2 etc...

     

    In Power Query add a custom column

     

    if [Month] = "January" then 1 else 

    if [Month] = "February" then 2 else 

    if [Month] = "March" then 3 else 

    if [Month] = "April" then 4 else 

    if [Month] = "May" then 5 else 

    if [Month] = "June" then 6 else 

    if [Month] = "July" then  7 else 

    if [Month] = "August" then 8 else 

    if [Month] = "September" then 9 else 

    if [Month] = "October" then 10 else 

    if [Month] = "November" then 11 else 

    if [Month] = "December" then 12 else  0

     

     

    Load your table and go to table view, highlight the Month column and in the ribbion, click on sort by and choose the new column you created.

     

    Thanks

    Joe

     

    If you found my answer helpful and it solved your issue, please accept as solution

     

4 Replies

  • Hi Anonymous 

     

    You need a sort column, so Jan = 1, Feb = 2 etc...

     

    In Power Query add a custom column

     

    if [Month] = "January" then 1 else 

    if [Month] = "February" then 2 else 

    if [Month] = "March" then 3 else 

    if [Month] = "April" then 4 else 

    if [Month] = "May" then 5 else 

    if [Month] = "June" then 6 else 

    if [Month] = "July" then  7 else 

    if [Month] = "August" then 8 else 

    if [Month] = "September" then 9 else 

    if [Month] = "October" then 10 else 

    if [Month] = "November" then 11 else 

    if [Month] = "December" then 12 else  0

     

     

    Load your table and go to table view, highlight the Month column and in the ribbion, click on sort by and choose the new column you created.

     

    Thanks

    Joe

     

    If you found my answer helpful and it solved your issue, please accept as solution

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello, Joe! Your solution seem to work except for one error I get when sorting by new column: 

       

  • I honestly haven't seen that error in such a case before. Are you using the most recent version of Power BI? I heard that there are some issues with this version. Have you tried to close the popup and check the visual?

    • Anonymous's avatar
      Anonymous
      Not applicable

      No, my version is a bit older. I decided to put ranks in a slicer box, using 1-2-3 instead of Jan-Feb-Mar, so your solution works perfectly for me. Thank you again! Have a nice day.