Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

How to sort the Month/Year in matrix.

Hello Comminity,

 

Can anyone guide on how sort the columns Month/Year, Have tried but couldnt get the desire reusults 

 

Please help.

 

  • Here is how i would do it.

     

    Make a new column at the table with the date.

    Make the coloumn look like this.

    Month/Year sorting = CONCATENATE(YEAR(Datoer[Date]);
    IF(MONTH(Datoer[Date])<10;
    CONCATENATE(0;MONTH(Datoer[Date]));
    MONTH(Datoer[Date])))
     
    Then choose the column with the year/month text and sort it by this new coloumn.
     
    This should make the text being sorted in correct year/month by calender.
  • Thim's avatar
    Thim
    7 years ago
    I have Highligted the new part in the Formula.
     
    Month/Year sorting = CONCATENATE(YEAR(Datoer[Date]);CONCATENATE("-";
    IF(MONTH(Datoer[Date])<10;
    CONCATENATE(0;MONTH(Datoer[Date]));
    MONTH(Datoer[Date]))))
     
    Hope this will help. :-)

6 Replies

  • Thim's avatar
    Thim
    Icon for Resolver V rankResolver V

    Here is how i would do it.

     

    Make a new column at the table with the date.

    Make the coloumn look like this.

    Month/Year sorting = CONCATENATE(YEAR(Datoer[Date]);
    IF(MONTH(Datoer[Date])<10;
    CONCATENATE(0;MONTH(Datoer[Date]));
    MONTH(Datoer[Date])))
     
    Then choose the column with the year/month text and sort it by this new coloumn.
     
    This should make the text being sorted in correct year/month by calender.
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Thim,

       

      Thnaks for the solution!

       

      Furthermore on this we would like to add the - between Year/Month, So can you guide me on this please.

      Current values: 201804

      Expected values: 2018-04

      • Thim's avatar
        Thim
        Icon for Resolver V rankResolver V
        I have Highligted the new part in the Formula.
         
        Month/Year sorting = CONCATENATE(YEAR(Datoer[Date]);CONCATENATE("-";
        IF(MONTH(Datoer[Date])<10;
        CONCATENATE(0;MONTH(Datoer[Date]));
        MONTH(Datoer[Date]))))
         
        Hope this will help. :-)
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello Team,

     
    I am trying to sort the month/year column but couldnt able to sort .
     
    Can anyone help on this as I am new to power BI and trying to create the sales dashboard.
  • Anonymous's avatar
    Anonymous
    Not applicable

    But how to sort in descending order like Jun 2024, May 2024, Apr 2024 etc. The above logic only works from Jan 24 etc to Dec 2024