Forum Discussion

gauravkumar16's avatar
gauravkumar16
Frequent Visitor
2 years ago

Sorting months spanning two years

Ritaf1983

 

 

I have months starting from Sep2022 to Sep2023. In line chart, they are not appearing chronologically.

Can anyone pls help how to achieve this.

 

6 Replies

  • DOLEARY85's avatar
    DOLEARY85
    Resident Rockstar

    Hi,

     

    you'll need to sort your column by something that runs in the correct order.

     

    Select your month-year column and use 'sort by column' on the 'column tools' tool bar then select the field to sort by. If you don;t have anything you could create something simple like a number that follows the month and year in your calendat table. e.g 

     

    Column = value(month('Calendar'[Date])&year('Calendar'[Date]))

     

    If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

     

    • gauravkumar16's avatar
      gauravkumar16
      Frequent Visitor

      Thanks Doleary58 for replying.

       

      I have a column as Month and Year in format "YYMMMM" so Sep 2022 is written as 092022.

       

      Now in line chart i have put this field in X-axis. Also, I have sorted the data by this column as you explained.

       

      But still it is not sorted chronologically whether you do ASC or DESC.

       

       

      Isn't it?

       

      • DOLEARY85's avatar
        DOLEARY85
        Resident Rockstar

        Can you check that your month year serial column is numeric?

  • gauravkumar16's avatar
    gauravkumar16
    Frequent Visitor

    Thanks DOLEARY85 for your replies.

     

    Actually I found out that data type for a calculated column was not correct.

    I had created a column with month and year e.g. Sep 2022.

    It's datatype should be date. It was text in my case.

    Once datatype is changed the line chart sorts itself chronologically.