Yes, you can double sort a pivot table. In Excel and Google Sheets, you apply multiple sort levels by sorting one field first, then holding the Shift key (Excel) or adding a second sort rule (Google Sheets) to sort by another field without losing the first sort order. This lets you order data by, say, region first, then by sales amount within each region.
What Double Sorting a Pivot Table Means
Double sorting (or multi-level sorting) means arranging your pivot table by two or more fields at once. For example, you might sort by Product Category (A to Z) and then by Total Sales (largest to smallest) within each category. The result is a table where categories are alphabetical, and within each category, products appear from highest to lowest sales.
This is different from sorting a single column, which only reorders one field. Double sorting is useful when you want a hierarchical view: first group by one dimension, then rank within that group. It works on both row labels and column labels, and on values within a row or column.
How Double Sorting Works in Excel
Excel's pivot table sorting is based on the field you right-click. To add a second sort level, you use the Shift key trick:
- Right-click a cell in the first column you want to sort by (e.g., the Product Category column).
- Choose Sort and then the order (A to Z or Z to A).
- Now right-click a cell in the second column (e.g., the Total Sales column).
- Hold the Shift key and then click Sort and choose the order (Largest to Smallest).
Holding Shift tells Excel to add this sort as a secondary level rather than replacing the first. If you don't hold Shift, the second sort replaces the first, and you lose the previous ordering. This works in most recent versions of Excel (2010 onward, including Microsoft 365).
Note that the exact menu labels can vary slightly by Excel version and language, but the Shift-key method is consistent. On a Mac, the same technique applies, but you might need to use the Command key instead of Shift in some versions—check your Excel's sort menu tooltip.
How Double Sorting Works in Google Sheets
Google Sheets pivot tables handle multi-level sorting differently. Instead of a Shift key, you add multiple sort rules in the pivot table editor:
- Click anywhere on your pivot table to open the Pivot table editor on the right.
- Under Rows or Columns, find the field you want to sort by first.
- Click the drop-down arrow next to that field and choose Sort by and select the order (e.g., A to Z).
- Add a second field to Rows or Columns if you haven't already.
- For the second field, click its drop-down and choose Sort by and select the order (e.g., Descending).
Google Sheets applies sorts in the order the fields appear in the Rows or Columns section. The first field is the primary sort, the second field is the secondary sort, and so on. You can reorder the fields by dragging them in the editor to change which sort takes priority.
Sorting by Values vs. Labels
You can double sort by labels (text) or by values (numbers). Label sorting is straightforward: A to Z or Z to A. Value sorting lets you order by the numeric totals in a row or column. For example, you might sort by the sum of sales, or by a percentage of a grand total.
In Excel, to sort by values, right-click a cell in the values area (like the Total Sales column) and choose Sort > Largest to Smallest. To add a second value sort, use the same Shift-key method on another values column. In Google Sheets, you choose the sort field in the pivot editor and select whether to sort by label or by a specific value (e.g., SUM of Sales).
Keep in mind that sorting by values in a pivot table can behave unexpectedly if you have multiple row fields. The sort applies to the innermost field by default, but you can change that in Excel by going to More Sort Options and choosing the field you want to sort by.
Common Problems and Fixes
Double sorting often fails because the second sort replaces the first. Here are the most common issues and how to solve them:
- Second sort replaces the first: In Excel, you forgot to hold Shift. Undo and retry with Shift held.
- Sort order not sticking after refresh: Pivot tables often lose custom sorts when you refresh data. To keep the sort, apply it again after refresh, or use a custom sort order in the field settings.
- Sorting by values not working as expected: Make sure you right-click on a value cell (not a label cell) and choose the appropriate sort option. In Google Sheets, check that you selected the correct value in the sort-by drop-down.
- Blank rows or items interfering: If you have blank cells in your source data, they can appear as separate items. Filter them out in the pivot table's row labels filter.
- Multiple row fields sorting only the innermost: In Excel, go to the field's sort options and choose "Sort by" and select the specific field you want to affect.
Alternatives to Double Sorting
If double sorting feels clunky, consider these alternatives:
- Sort the source data first: Sort your raw data by multiple columns before creating the pivot table. The pivot table will inherit that order (as long as you don't change the field order).
- Use a custom sort order: In Excel, you can define a custom list (e.g., High, Medium, Low) and apply it to a field. This works well for non-alphabetical orders.
- Group fields: Group dates or numbers into buckets (e.g., months, quarters) to reduce the number of sort levels needed.
- Use a regular table: If you don't need aggregation, a sorted Excel table or Google Sheets range might be simpler.
Frequently Asked Questions
Why does my second sort not work in Excel?
Most likely because you didn't hold the Shift key when clicking Sort. Without Shift, Excel replaces the previous sort. Also, make sure you right-click on a cell in the column you want to sort, not the header.
Can I sort by more than two fields?
Yes. In Excel, hold Shift and apply each additional sort in the order you want. In Google Sheets, add more fields to Rows or Columns and set their sort order individually. The order of fields determines priority.
Does double sorting work on column labels too?
Yes. You can sort row labels and column labels independently. For example, sort rows by sales, and columns by date. The same Shift-key method applies in Excel, and in Google Sheets you set sorts for both Rows and Columns sections.
How do I sort a pivot table by a calculated field?
In Excel, right-click a value cell in the calculated field column and use the sort options. In Google Sheets, add the calculated field as a value, then choose it in the sort-by drop-down for the row or column field.
My sort disappears when I refresh the pivot table. What do I do?
This is a known limitation. After refreshing, reapply the sort. To automate, you can record a macro in Excel that applies the sort and refresh, then run it after each data update. In Google Sheets, the sort usually persists, but if not, reapply it in the editor.
Can I sort by a custom order like High, Medium, Low?
Yes. In Excel, create a custom list in the Advanced options (under File > Options > Advanced > Edit Custom Lists), then use that list as the sort order. In Google Sheets, you can create a helper column with numbers and sort by that.