Forum Discussion

afaro's avatar
afaro
Helper III
1 year ago
Solved

Can I sort matrix visual based off a specific column?

Let's say I have table like this: 

 

CountryC1C2C3
ProductSalesSalesSales
P1102050
P2301060
P350010

 

Product is the rows in the matrix, Country is in the columns and Sales is the measure in the values. 

 

I want to sort let's say sort by Sales ascending in country C2, so I would get something like this: 

CountryC1C2C3
ProductSalesSalesSales
P350010
P2301060
P1102050

 

I want to do it by specific column like this. 

7 Replies

  • Yes, change the column total to only include C2. 

     

    Measure = if(ISINSCOPE('Table'[Country]),sum('Table'[Sales]),CALCULATE(sum('Table'[Sales]),'Table'[Country]="C2"))

     

     

    Sort by the column total.

     

     

     

    Hide the column total.

     

     

    • afaro's avatar
      afaro
      Helper III

      I want to have the option to change by any country whenever I want instead of keeping static just for C2. So, if I want to do by C1 and C3, then end user should be able to do that. 
      To add, I don't want to create a measure where I remove the columns from matrix and explicitly add the country in the measure for example CALCULATE([Sales], Country = "C2") and so on. This is a solution but not something I am looking for since I prefer having to keep the columns.  

      • lbendlin's avatar
        lbendlin
        Super User

        Sure, have a disconnected slicer for the country selection and in the measure read the current slicer value.