Survey Tabulation > Cell contents > Sorting rows and columns
 
Sorting rows and columns
Sometimes it is useful to sort your tables, so that you can see at a glance which is the most important or popular response. Sorting tables is sometimes called ranking. To understand how it works, first let's consider an unsorted table from the Museums sample data set, displaying What Respondents Remember by Holds Biology Qualification:
Remember by Biology - unsorted
The rows and columns in the unsorted table are displayed in the order in which they are stored in the source data file. Suppose you want to sort the table so that the rows that contain more respondents appear before those containing fewer respondents. When you sort rows, you need to select the column on which you want to sort. For example, you could sort the rows by their values in the base column, by selecting biology{Base} in the Column Sorting list box of the Preferences tab. See To sort a table on a row or column for more information.
Now look at the table:
Remember by Biology - sorted on Base column
If you compare this table with the unsorted table, you will notice that the rows have been reordered, making it easy to see which categories were most popular. Although you generally want to sort the rows on the base column, you are not restricted to doing this. For example, you can sort the rows on the values in the Yes column, by selecting biology{Yes} in the Column Sorting list box.
Here is the table:
Remember by Biology - sorted on Yes column
Notice that the order of the rows has changed to reflect the values in the Yes column.
You can sort the columns, just like you can sort the rows. When you sort columns, you need to specify the row on which you want to sort. For example, you can sort columns by their values in the base row by selecting remember{Base} in the Row Sorting list box.
Here is the table:
Remember by Biology - sorted on Base row
Notice that now the order of the Yes and No columns has been reversed, making it easy to see that more respondents chose the No category.
And of course, you can sort both rows and columns in the same table, by selecting remember{Base} in the Row Sorting list box and biology{Base} in the Column Sorting list box.
Here is the table:
Remember by Biology - sorted on Base row and column
You have probably noticed that all of the tables shown in this topic have only one item of cell contents and you may be wondering what happens when the table contains additional cell contents. The answer is that if the table contains more than one item of cell contents, the sort is always based on the first item of cell contents. When creating sorted tables that contain more than one item of cell contents, you therefore need to give some consideration to the order in which you specify the items of cell contents.
Notes and general limitations
If there is more than one item of cell contents, the first item is always used for the sort.
Values are always sorted in descending order.
Sorting rows that contain cumulative column percentages or columns that contain cumulative row percentages is not recommended, as the reordered percentage values do not give meaningful results.
Axes are not sorted if they contain a combination of nesting and concatenation.
You cannot use an element that is inside a net to sort the other axis of the table.
You cannot sort an axis that contains net elements in an outer nest level. Any sorting that would apply to the axis is ignored.
There are a number of special rules that apply when sorting axes that contain special elements. See Sorting special elements for more information.
See also
Sorting nested and concatenated tables
Sorting net elements
Sorting special elements
Sorting grid tables
To sort a table on a row or column
See also
Cell contents