Forum Discussion

rarora20's avatar
rarora20
Regular Visitor
8 years ago
Solved

Sorting by Month Number

Hello,

 

I have a month and year column. I have created a conditional column which gives me the month number based on the month name. When I try to sort the data by the conditional column(Number), it gives me the month names as Jan Oct Nov Dec Feb Mar Apr May Jun Jul Aug Sept instead of the ascending month names. Please help. Thank you!

 

  • parry2k's avatar
    parry2k
    8 years ago

    rarora20 make sure to change date type for your new column M# to whole number, it is string , you will not get correct sort because with string sort will go like this

    1

    10

    11

    12

    2

    3

    4

    5

    6

    7

    8

    9

     

    and that is the reason you see Jan, Oct, Nov, Dec and so on..

13 Replies

    • select the data tab
    • select the column: Month - makse sure that month is your defult
    • "Sort By Column": Number"
    • rarora20's avatar
      rarora20
      Regular Visitor

      Tried it. Still giving me the same result. 

  • rarora20

    Why doing such a long process. Instead try doing this.

    Goto queryeditor, duplicate your month column and transform to MonthNumber and rename it any name and apply.

    Now in modeling tab , use this new named column to sort the month column.

    • rarora20's avatar
      rarora20
      Regular Visitor

      pxg08680 how do I transform to month number. I am new to this. Help me with some steps. I have a month name column. Thank you!

      • pxg08680's avatar
        pxg08680
        Resolver III

        rarora20

        Do these steps

         

        STEP1: Goto Home, EditQueries.

        STEP2: Select the Month column that you have, right click and goto transform-->Month-->Month. This gives you month numbers.

        STEP3: For same column right click and rename it to MONTHNUMBER.

        STEP4: Close& Apply.

        STEP5: Select the Month column from your data and got to modeling tab, sort column, select the newly created column, sort by MONTHNUMBER.

         

        This should work.