Forum Discussion

jcastr02's avatar
jcastr02
Post Prodigy
1 year ago
Solved

Sort Matrix by AttributeSort column

I have a matrix visual and I'd like to be able to sort the columns in a specific order.  I created a conditional column within the data table to create a numerical number based on the "Attribute" Col...
  • v-achippa's avatar
    1 year ago

    Hi jcastr02,

     

    Thank you for reaching out to Microsoft Fabric Community.

     

    Power bi does not apply custom sort order to the fields used in the columns section of a matrix visual. Even if the column is sorted correctly in the data model, the matrix will still show the column headers in alphabetical order by default. So please follow below steps:

     

    • Create a new supporting table with the required Attribute values and a custom sort order column.

      AttributeSortTable =

      DATATABLE(

          "Attribute", STRING,

          "SortOrder", INTEGER,

          {

              {"Area Name", 1},

              {"Specialty", 2},

              {"Central Pharmacy", 3},

              {"Midwest Specialty", 4},

              {"New England Spec", 5}

          }

      )

       

    • In this new table, go to the Attribute column and use Sort by Column and choose SortOrder.
    • Use this new Attribute column in the Columns section of the matrix visual instead of the original one.

     

    If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

     

    Thanks and regards,

    Anjan Kumar Chippa