Sort a pivot table
Right-click any number in the column you want to sort by and choose Sort, then Sort Largest to Smallest (or Smallest to Largest). To sort by the labels, right-click a row label and choose Sort A to Z. The sort stays in place after a refresh.
Syntax
Right-click a value cell > Sort > Sort Largest to Smallest| Part | What it is |
|---|---|
Sort A to Z / Z to A | Sorts the row labels alphabetically or numerically |
Sort Largest to Smallest | Sorts rows by the value column you right-clicked |
More Sort Options | Choose a specific value field, or sort manually by dragging |
Manual | Drag a row label to a new position; Excel keeps that order |
Examples
Rows: Region
Values: Sum of Revenue
Right-click a revenue number > Sort > Largest to SmallestResult: Regions ordered by revenue, best first; the Grand Total stays at the bottom.
Rows: Product
Values: Sum of Units
Right-click a units number > Sort > Smallest to LargestResult: The weakest product at the top, the best seller at the bottom.
Rows: Region, Rep
Sort the rep level by Sum of Revenue largest to smallestResult: Within each region the reps are ordered by revenue; the regions keep their own order.
Sorting applies to the level you clicked, not the whole table.
Common mistakes
- Sorting by a value sorts only inside each group: that is by design for nested fields; sort the outer field separately.
- Months sort alphabetically (Apr, Aug, Dec): the month labels are text, so group a real date field instead or use a custom list.
- The sort flips back after a refresh: open More Sort Options and check that AutoSort is set to the field you want.
- You cannot drag a label to reorder: the field is set to sort automatically, so switch it to Manual in More Sort Options first.
Practice Sort a pivot table
These drills check your answer on live data, free, no account needed.
- Best region firstShow total Revenue by Region, sorted so the region with the highest revenue is at the top.
- Products by units, smallest firstShow total Units by Product, sorted from the fewest units to the most.
Questions
How do I sort a pivot table by the grand total column?
Right-click any number in the Grand Total column and choose Sort, Largest to Smallest. Row labels reorder by their total.
How do I sort a pivot table in a custom order?
Right-click a label, choose Sort, More Sort Options, Manual, then drag labels into place. Or define a custom list under File, Options, Advanced, Edit Custom Lists and sort A to Z.
Why is my pivot table not sorting correctly?
Usually the field is nested under another field, or the labels are text that look like numbers or dates. Sort the correct level and check the source data types.
Related
- Top 10 filterUse Value Filters, Top 10 to keep only the top 5, the bottom 3 or the items that make up 80 percent of a total. Steps, the Items, Percent and Sum modes.
- Filter a pivot tableFour ways to filter a pivot table: the row label dropdown, the Filters area above the table, Value Filters on totals, and slicers. Examples and catches.
- Group dates by month, quarter and yearGroup a date field in a pivot table by months, quarters and years with right-click, Group, and get year by month breakdowns. Auto grouping, ungrouping, weeks.
Previous: Sum, Count and Average in a pivot tableNext: Filter a pivot table