Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Order matrix table depending on which row is selected

Hi,

 

I have a matrix table with multiple row levels. For example, the first rows/levels is country, and then you can click on the country to show its provinces and states.

 

I want the default table to be ordered alphabetically by country. But then, after I click on a country and the list of states/provinces show, I want the table to be orderd by numeric value of a different column, for example gdp. 

 

Is there a way to to this?

 

TIA 

2 Replies

  • Anonymous , i doubt that is possible. You may use bookmarks and button to switch between country and state view

  • Adamboer's avatar
    Adamboer
    Responsive Resident

    To achieve this, you can use a combination of the SORT function and conditional formatting rules in Google Sheets or Microsoft Excel. Here are the steps:

    1. First, sort the entire table by the "Country" column alphabetically, so that it's in the desired order by default.

    2. Next, apply conditional formatting to the "GDP" column, so that it highlights the highest values in green and the lowest values in red. To do this in Google Sheets, select the "GDP" column and click on "Conditional formatting" from the "Format" menu. Then, set up a custom rule that compares each cell in the column to the maximum and minimum values, and applies the appropriate background color.

    3. Finally, apply a custom sort order to the "State/Province" column that takes into account the color of the corresponding "GDP" cell. In Google Sheets, you can do this by selecting the entire table (including the header row), and clicking on "Data" -> "Sort sheet by column". Then, choose the "State/Province" column, and set up a custom sort order that first sorts by the "Country" column (as before), and then by the "GDP" column in descending order, so that the highest values appear at the top of each group of states/provinces.

    With these steps, your matrix table should be sorted alphabetically by country by default, but dynamically re-order itself by GDP value when you click on a country to view its states/provinces.