Forum Discussion

averilboyle's avatar
averilboyle
Frequent Visitor
9 years ago
Solved

Month Name in sorting order in Direct Query

Hi

 

I have a direct query where I have added a new column from the date field.  In this column I have the following formula:

 

MonthName = SWITCH(MONTH(Query1[Date Raised]),1,"January",2,"February",3,"March",4,"April",5,"May",6,"June",7,"July",8,"August",9,"September",10,"October",11,"November",12,"December")

 

The problem I have is that it is sorting the data alphabetically, so now December comes before September!!

 

Any idea how I can put it in numerical order?

 

Thanks

  • Hi,

     

    Create a column that is xxx = month(query1[date raised]))

    Idk if you already have it already, if you have it, no need to create it :D, and then, you just need to sort the MonthName by the column that gives the month number :P

     

     

7 Replies

  • Salvador's avatar
    Salvador
    Responsive Resident

    Hi,

     

    Create a column that is xxx = month(query1[date raised]))

    Idk if you already have it already, if you have it, no need to create it :D, and then, you just need to sort the MonthName by the column that gives the month number :P

     

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    I too faced similar challenge of sorting month in Direct query mode of date hierarchy.

     

    So after creating column with Switch function as month function only gives you number of the month create one more column for month number MonthNum.
    Sort column according to month number and then add this month to hierarchy and to Visualisation, then table gives you in sorting order.

     

    Note: Remember to sort column MonthNum and then add it hierarchy.