This article describes how to take a table with a default sort order:
And sort it by a specific column or row:
Method
Sorting tables manually
On a table there are three ways to manually sort the data. You can drag rows or columns manually, or you can sort the rows and columns based on the current values of a table statistic or their labels.
Dragging and dropping rows in the table is appropriate if you just need to make a few changes. However, if you need to reorder a whole table, the built-in table sort function is more efficient. Consider the following technology brand ratings table. The default sort in this case is the initial order of the brand variables as they were shown in the questionnaire.
With the built-in function, you can sort by labels or values. To sort by the brand names in alphabetical order:
- Right-click on a row header and select Sort by > Labels – Ascending.
To sort the brands in descending order according to the average brand rating,
- Right-click on the column header and select Sort by > Values – Descending > Average. Note that you can sort by any of the available cell statistics that are currently being displayed in the table.
Sorted Ascending by Labels (Brands)
Sorted Descending by Brand Rating (Average)
Automatic sorting
Some additional table sorting functions can be found in the Automation menu in Q. These automated functions include various Rules that provide additional functionality and flexibility beyond the basic sorting options in Q. Most of the sorting functions can be found under the menu Automate > Browse Online Library > Sort/Reorder Rows or Columns.
By definition, a Rule is applied to an individual table in Q. For example, Sort Rows (Automatically Updates when Data Changes) applies a sort to a specific table. The options allow you to set specific parameters such as which column to sort by, the sort order and rows to include/exclude from the sort operation.
As the name indicates, the sort will execute again automatically when the underlying data is changed or updated.
How to sort charts
When displaying a table as a chart in Q, the chart will adopt whatever sort order was applied to the table, whether applied manually or by an automated sorting function. Take the previous example where we sorted technology brands by likelihood to recommend. When changed to a bar chart using
- View > Show Data as > Bar Chart,
The chart is sorted in descending order just as the table was.
Sorting in the Data tab
You can also sort in the Data tab, which can assist when you need to check the raw data. In Q, you never modify the underlying data file, and so any sorting is stored in the project file. For this reason, Q requires that a unique identifier be set before data sorting can be enabled. You can do this using the Case IDs dropdown box under the menus in the Data tab.
- In the Case IDs dropdown box, select Unique Identifier
Once the identifier has been set, you can sort by any column by right-clicking on the column header and select one of the sorting options: Sort Data by This Column – [Ascending | Descending].
Next