Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Month Name Sorting by Month Number

Hi,

         I have "order Date" column, I created MonthName = vw_test[order Date].[Month]. in order to sort "Month name", I created another column "month number" ( used switch fuction to convert month name to month number). I try to use month number sorting month name in correct order. But got a error message: cant be sort one column based on other column. What I did wrong? Thanks!

5 Replies

  • Hi Anonymous , do you try to sort using the option select graph and clic on sort?

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Microsoft Employee

    Hi Anonymous ,

     

    Rather than create a calculated column "month number" with DAX, add a conditional column in Query Editor mode, still to convert month name to month number with the same logic. Then, in data view mode, sort by that conditional column.

     

    Best regards,

    Yuliana Gu

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Gu,

                    Unable to use conditional column. "month name" column is caculated (MonthName = vw_test[order Date].[Month]). In If statement, unable to find month name.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

     

    An alternative solution to the above might be to add the month number column to your visual and sort by it like you would normally. You can then hide the column compeltely by making it the first column in your visual, renaming it to something short, and then narrow it completely.

    • Anonymous's avatar
      Anonymous
      Not applicable

      if table, this method works. I use month name as a slicer.