Forum Discussion

Ania26's avatar
Ania26
Icon for Helper IV rankHelper IV
1 year ago
Solved

Sorting by the last column

Hello,   CountryValueYear USA 1 2023 France 3 2023 Canada 1 2023 USA 2 2024 France 1 2024 Canada 6 2024   For the data above , I have amtrix table: How ca...
  • freginier's avatar
    1 year ago

    Hey there!

     

    You could try creating a Sort Column in Power Query

    • Since the matrix does not allow direct sorting by specific columns, create a calculated column:
    • In Power Query, add a new column:
      SortColumn = 'YourTable'[2024] // Ensure this refers to the 2024 column
    • Sort the Matrix Table Using This Column

      • Go to the Fields pane in Power BI.
      • Click on the Country column.
      • Select Sort by Column → Choose SortColumn.
    • Ensure Sorting Order

      • If the sort is incorrect, adjust sorting in Visual Level Filters:
        • Click on the matrix table.
        • Under Sorting & Filtering options, select 2024 columnSort Descending.

    If sorting directly is not working, create a DAX measure to rank countries based on the 2024 values:

    Rank2024 = RANKX(ALL('YourTable'), SUM('YourTable'[2024]), , DESC, DENSE)

    Then, sort the matrix by Rank2024 instead.

     

    Hope this helps!

    😁😁