How to Sort on Multiple Fields in an Excel 2019 Data List
When you need to sort a data list on more than one field, you use the Sort dialog box (shown in the figure). And you need to sort on more than one field when the first field contains duplicate values and you want to determine how the records with duplicates are arranged. (If you don’t specify another field to sort on, Excel just puts the records in the order in which you entered them.)
The best and most common example of when you need more than one field is when sorting a large database alphabetically in last-name order. Say that you have a database that contains several people with the last name Smith, Jones, or Zastrow (as is the case when you work at Zastrow and Sons). If you specify the Last Name field as the only field to sort on (using the default ascending order), all the duplicate Smiths, Joneses, and Zastrows are placed in the order in which their records were originally entered. To better sort these duplicates, you can specify the First Name field as the second field to sort on (again using the default ascending order), making the second field the tie-breaker, so that Ian Smith’s record precedes that of Sandra Smith, and Vladimir Zastrow’s record comes after that of Mikhail Zastrow.
To sort records in a data list using the Sort dialog box, follow these steps:
- Position the cell cursor in one of the cells in the data list table.
- Click the Sort button in the Sort & Filter group on the Data tab or press Alt+ASS.
Excel selects all the records of the database (without including the first row of field names) and opens the Sort dialog box. Note that you can also open the Sort dialog box by selecting the Custom Sort option on the Sort & Filter drop-down button’s menu or by pressing Alt+HSU.
- Select the name of the field you first want the records sorted by from the Sort By drop-down list.
If you want the records arranged in descending order, remember also to select the descending sort option (Z to A, Smallest to Largest, or Oldest to Newest) from the Order drop-down list to the right.
- (Optional) If the first field contains duplicates and you want to specify how the records in this field are sorted, click the Add Level button to insert another sort level, select a second field to sort on from the Then By drop-down list, and select either the ascending or descending option from its Order drop-down list to its right.
- (Optional) If necessary, repeat Step 4, adding as many additional sort levels as required.
- Click OK or press Enter.
Excel closes the Sort dialog box and sorts the records in the data list using the sorting fields in the order of their levels in this dialog box. If you see that you sorted the database on the wrong fields or in the wrong order, click the Undo button on the Quick Access toolbar or press Ctrl+Z to immediately restore the data list records to their previous order.
By default, when you perform a sort operation, Excel assumes that you’re sorting a data list that has a header row (with the field names) that is not to be reordered with the rest of the records in doing the sort. You can, however, use the Sort feature to sort a cell selection that doesn’t have such a header row. In that case, you need to specify the sorting keys by column letter, and you need to be sure to deselect the My Data Has Headers check box to remove its check mark in the Sort dialog box.