Sorting Data in a Pivot Table: A Complete Guide

Charts & pivot tables · Updated November 23, 2026

To sort data in a pivot table, click any cell inside the row or column label you want to sort, then use the Sort buttons on the Data tab (A→Z or Z→A) or click the drop-down arrow on the field header and choose Sort A to Z or Sort Z to A. For values, right-click a value cell and choose Sort, then select the order you want (e.g., Largest to Smallest). This article explains every sorting method, including manual drag-and-drop, custom lists, and sorting by subtotals, with step-by-step instructions for Excel 365.

Why Sorting in a Pivot Table Is Different

Unlike a regular worksheet range, a pivot table’s layout is dynamic. When you sort a field, Excel reorders the underlying items in that field’s cache, which affects every place that field appears—including multiple columns or rows that use the same field. This is why you can’t simply select a few cells and sort them like a normal range; the sort applies to the entire field. Also, pivot tables automatically sort new items alphabetically by default, which can be annoying if you want a custom order. Understanding this behavior helps you avoid the common mistake of trying to sort only a subset of rows.

Basic Sorting: Row and Column Labels

The quickest way to sort labels is to use the field header’s drop-down arrow. Click the arrow on the row label (e.g., “Product”) and choose Sort A to Z or Sort Z to A. This sorts all items in that field alphabetically. Alternatively, click a cell in the row label column, then go to the Data tab and click the A→Z or Z→A button. The same works for column labels. For example, if you have months as columns, clicking a month header and choosing Sort Oldest to Newest will arrange them chronologically (Excel recognizes date formats).

Sorting by Values (Largest to Smallest)

To sort by the numbers in the values area, right-click any value cell (like a sum or count) and choose Sort, then select Largest to Smallest or Smallest to Largest. This reorders the row labels based on the values in that column. For instance, if you have sales by product, right-click a total cell and pick Largest to Smallest to see your top-selling products first. This works for any value field, including averages, counts, and percentages. Note that if you have multiple value fields (e.g., Sum of Sales and Count of Orders), the sort applies to the column you right-clicked, not all columns.

Manual Sorting with Drag and Drop

Sometimes you want a specific order that isn’t alphabetical or numeric—like a custom sequence of regions (North, South, East, West). You can manually drag items in the row label area. Select the cell containing the item you want to move, hover over its border until the cursor becomes a four-sided arrow, then drag it up or down to the desired position. Excel will show a thick line where the item will drop. This manual order is preserved even if you refresh the pivot table, but only if you don’t re-sort with a command. For column labels, drag left or right. This method is ideal for custom orders that aren’t based on values.

Using Custom Lists for Non-Standard Orders

If you frequently need a specific order (like weekdays or a custom product hierarchy), you can create a custom list in Excel and then apply it to the pivot table. Go to File > Options > Advanced, scroll to General, and click Edit Custom Lists. Enter your list items (e.g., “Low, Medium, High”) and add it. Then, in the pivot table, click the field header drop-down, choose More Sort Options, select Manual, and then click Advanced. In the AutoSort dialog, check Using custom lists and pick your list. Excel will sort the field according to that list. Note that this works only for text fields, not numeric values.

Sorting by Subtotals and Grand Totals

If your pivot table has subtotals (e.g., per region), you can sort each group independently by its subtotal. Right-click the subtotal cell for a group (like the total for “East”), choose Sort, and then select the order. This sorts only that group’s items, not the entire field. To sort the groups themselves by their grand totals, right-click a grand total cell in the values area and choose Sort. For example, with regions as rows and products as columns, right-click the grand total for a product column to sort regions by that product’s sales. This gives you fine-grained control over the presentation.

Common Problems and Troubleshooting

Two frequent issues arise when sorting pivot tables. First, if you sort by values and then add a new item, the new item may appear at the bottom instead of in the correct sorted position—this is because the sort is static until you refresh. To fix, refresh the pivot table (right-click > Refresh) or re-apply the sort. Second, if you have a calculated field or a custom formula, sorting may not work as expected because the values are computed after the sort. In that case, sort by the underlying source data instead. Also, if you have blank cells in the label field, they may sort to the top; you can hide them by using the field’s filter options.

Frequently Asked Questions

Why does my pivot table sort alphabetically even after I sort by values? This happens if you have multiple row fields (e.g., Region and Product). When you sort by values, only the innermost field is sorted; the outer field remains in its default order. To sort the outer field by values, right-click a value cell in the outer field’s group and sort again.

Can I sort by a custom order like High, Medium, Low? Yes, use a custom list as described above. Create the list in Excel Options, then apply it via More Sort Options > Advanced > Using custom lists. This overrides alphabetical sorting.

How do I sort column labels by their values? Right-click a value cell in the row area (like a product name) and choose Sort, then select Largest to Smallest. This will reorder the column labels based on the values in that row.

Why does my manual drag-and-drop order reset when I refresh? Manual order is preserved unless you apply a different sort. If you refresh and the order resets, it’s likely because the pivot table is set to sort automatically. Go to the field’s More Sort Options and choose Manual to keep your drag order.

Can I sort a pivot table by a value field that is not displayed? No, you can only sort by fields that are currently in the Values area. If you need to sort by a field you’re not showing, temporarily add it, sort, then remove it.

Alternatives and Advanced Tips

If you need more complex sorting—like sorting by multiple criteria or a custom formula—consider using the SORT function in Excel 365 on the source data before creating the pivot table. For example, with data in A1:C100, you can create a sorted copy using =SORT(A1:C100, 2, -1) to sort by column 2 descending. Then base the pivot table on that sorted range. Another option is to use Power Pivot’s DAX measures, but that’s overkill for most users. For quick one-off sorts, the built-in methods are sufficient. Remember that pivot tables are meant to be interactive; you can also use slicers to filter, which doesn’t affect sort order but helps narrow data.

Related

Try it: the Percentage Formula Generator: percent of, percent change, increase and decrease, with the formula.

More in Charts & pivot tables

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.