Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
2 years ago
Solved

SORT FOR A YEAR

Hi how are you, I want to sort my data by YEAR but I haven't managed to do it, I'm loading the data into an array and this is the detail of the array


And so it shows me the data in the matrix

CUSTOMER 2021 2022 2023 2024
=============================================
Customer 01 323 102 44 189


And I want you to order me that way.


CUSTOMER 2024 2023 2022 2021
=============================================
Customer 01 189 44 102 323


saludos

2 Replies

  • Thank you for your reply, I had already made a code which worked for me, I took it from another solution and used it as an example.

    Create another table

    YearOrder = DATATABLE("Year",INTEGER,"YearDesc",INTEGER,{{2021,2024},{2022,2023},{2023,2022},{2024,2021 }})
    I related it to the base table where the year is, then in the matrix I showed the Year value of the new table, that way I sort the data by year.

    Thank you very much and I leave the link from which I took the example, it was for months but the truth is that it also helped me to adjust it to the YEAR.

    https://community.fabric.microsoft.com/t5/Translated-Spanish-Desktop/Ordenar-por-a%C3%B1o-y-mes-una-matriz/m-p/3011783#M528499


  • You will need to create a column

     

    SortYear = YEAR('CALENDAR'[DATE])*-1

     

    Then, select the Year column used in Matrix and  go to the 'column tools' from the menu bar and select the SortYear Column from 'Sort By Column' drop down. 

     

    This will gives you the expected result.