Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Year Sort

I've made a calculated column for Month and year and It's showing as below:

 

The sorting is not correct it seems. I want the Month and Year to be sorted. 

 

Desired Output

 

DealMonth Year
xyzJan'2025
xyzFeb'2025
xyzJan'2026
xyzFeb'2026

 

How can I get the sorting right? Present I've sorted month year by Month.

 

Below are the formulas I've used:

 

Month Year = VIEW_FORECASTREVENUE[Month Name] & "'" & VIEW_FORECASTREVENUE[Year]
 
Month Name = SWITCH(VIEW_FORECASTREVENUE[Month],1,"Jan",2
,"Feb",3,"Mar",4,"April",5,"May",6,"June",7
,"July",8,"Aug",9,"Sep",10,"Oct"
,11,"Nov",12,"Dec")
 
Year = YEAR(VIEW_FORECASTREVENUE[EXPECTEDINMONTH])
 
Regards,
Himanshu
  • Hi Anonymous 

    Create your column as actual dates and then they will sort properly.

    Try this to create the column

    Month Year = DATE(YEAR(VIEW_FORECASTREVENUE[EXPECTEDINMONTH]), VIEW_FORECASTREVENUE[Month], 1)

    You should get a column of type DateTime that should sort chronologically

    Regards

    Phil

  • Hi Anonymous 
    You can create a numeric key like 202101 for January 2021 and then use this column for sorting the Month-Year column using the sort by column option.

7 Replies

  • Hi Anonymous 

    Create your column as actual dates and then they will sort properly.

    Try this to create the column

    Month Year = DATE(YEAR(VIEW_FORECASTREVENUE[EXPECTEDINMONTH]), VIEW_FORECASTREVENUE[Month], 1)

    You should get a column of type DateTime that should sort chronologically

    Regards

    Phil

    • Anonymous's avatar
      Anonymous
      Not applicable

      Can you please show what actually you mean by "Actual dates". It is not clear to me.

       

      Regards

      • PhilipTreacy's avatar
        PhilipTreacy
        Super User

        Anonymous 

        Just added an example of how to create the dates based on your data.

        Month Year = DATE(YEAR(VIEW_FORECASTREVENUE[EXPECTEDINMONTH]), VIEW_FORECASTREVENUE[Month], 1)

         

        Regards

        Phil

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you !!!

       

      It resolved my issue.

       

      Regards,

      Himanshu

  • Hi Anonymous 
    You can create a numeric key like 202101 for January 2021 and then use this column for sorting the Month-Year column using the sort by column option.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks it solved my issue.

       

      Regards,

      Himanshu