Sorting data in a table can be done in various ways depending on how the table is created. For our built-in drag and drop tables, you can sort via the column's right click menu, but this sort order will be fixed and used on all tables. If you want the rows sorted based on data in each individual table and you want the sort to update based on updated data, you should use the Sort Rows (Automatically Updates When Data Changes) rule, which can also be applied to a variety of tables.
This article describes how to go from an unsorted table...
...to a table that has been sorted automatically by row according to a specified column using a rule:
Requirements
- A table.
Method
- Select your table.
- Go to Data > Rules in the object inspector.
- To apply the rule, select the Plus (+) > Sort/Reorder Rows or Columns > Sort Rows (Automatically Updates When Data Changes). This will add a new Rule to your table for sorting.
- Select the Sort method for ascending or descending.
- Choose the Column selection method. This can be based on the largest, last, or a specified column. If you only have a single column, this can be left as default.
- The Exclude from sort (in addition to NET/SUM) option ensures that any specified rows remain at the bottom of the table. In this example, Don't care has been entered to prevent it from being sorted. This text is not case-sensitive.
- OPTIONAL: The Never exclude from sort field can be used when the rule automatically sorts a category that shouldn't be sorted. For example, if you have the word Others in your row label, adding Others to this field will ensure it is not mistaken for an Other/Specify option and left at the bottom of the table. This text is not case-sensitive.
- Press OK.
Note the following:
- The table will be sorted using the first statistic shown on the table.
- By default, if there are multiple columns in the table, the rule will sort according to the largest column (according to the Column Sample Size in the Statistics - Below). Using this option:
- This script will have no effect when Column Sample Size is not available from the Statistics - Below.
- If two or more columns have the same value for Column Sample Size then the table will be sorted according to the right-most column with that value of Column Sample Size.
- Rows that look like they are Don't Know, Other/Specify, All of these, or None of these responses will be left at the bottom of the table, as will NET and SUM rows.
- Values of NaN are treated as the largest possible negative number for the purpose of sorting, which means that they will always be placed below other rows when sorting from highest to lowest (except those rows that have been excluded from the sort).
- When the table has spans in the rows, the rows of the table will be sorted within the spans.
- When the underlying data updates, the table sorting will automatically update according to the rule conditions.
- When the rule is applied to multiple tables being sorted by column name, the exact same column name must be in all tables the rule is applied to. If you want to change the sorting settings for a particular table, you will need to create a "fresh" version of the rule from the Automate menu to adjust the settings for that table.
Next
How to Sort Labels in an Ascending or Descending Order
How to Automatically Sort Tables to Show Patterns in the Data