To sort pivot table columns in Excel, click the drop-down arrow on the column label (usually in the header area of the pivot table) and choose Sort A to Z or Sort Z to A. You can also right-click a cell in the column you want to sort, select Sort, and pick an option. For more control, use the More Sort Options dialog to sort by values in a specific row or by a custom list.
Why Sorting Pivot Table Columns Matters
Pivot tables are powerful for summarizing data, but the default column order often follows the source data’s order or alphabetical order, which may not be the most insightful. Sorting columns can help you quickly identify trends, rank categories, or present data in a logical sequence. For example, if you have sales data by month, sorting columns chronologically (Jan, Feb, Mar) is more intuitive than alphabetical (Apr, Aug, Dec). Sorting by values (e.g., highest total sales first) can highlight top-performing products or regions at a glance.
How to Sort Pivot Table Columns: Step-by-Step
The method depends on whether you’re sorting by the column labels themselves (e.g., product names) or by the values in the cells (e.g., sum of sales).
- Sort by column label (text): Click the drop-down arrow next to the column label (e.g., “Product”). Select Sort A to Z or Sort Z to A. This rearranges the columns alphabetically.
- Sort by value in a specific row: Right-click a cell in the row that contains the values you want to sort by (e.g., the “Grand Total” row). Choose Sort > Sort Largest to Smallest or Sort Smallest to Largest. This reorders columns based on the values in that row.
- More options: Use the drop-down arrow > More Sort Options. In the dialog, you can choose to sort by Ascending or Descending, and specify a Sort By field (e.g., a specific row label) and a Sort Order (e.g., “Sum of Sales”). You can also select a Custom List for a predefined order (like month names).
Note: In Excel for Microsoft 365 on Windows, these steps work as described. On a Mac, the right-click menu is similar, and the drop-down arrows are available. In Excel for the web, right-click options are limited, but you can still use the drop-down arrows on the field buttons.
Sorting by Values vs. Labels: What’s the Difference?
Sorting by labels reorders columns based on the text in the column headers (e.g., product names, dates). Sorting by values reorders columns based on the numbers in a particular row (e.g., total sales, average price). For example, if you have a pivot table with products as columns and months as rows, sorting by “Grand Total” row will put the highest-selling product first. Sorting by the “January” row would put the product with the highest January sales first. This distinction is crucial because sorting by values gives you data-driven insights, while sorting by labels is purely organizational.
Common Problems and How to Fix Them
Sometimes sorting doesn’t work as expected. Here are common issues and solutions:
- Sorting doesn’t affect the pivot table correctly: Ensure you are clicking the correct drop-down arrow (the one on the column field, not the row field). If you right-click a cell, make sure it’s within the column you want to sort.
- Sort order resets after refreshing: Pivot tables often revert to the default order when refreshed. To preserve your sort, you can set a default sort order in the Field Settings dialog (right-click the field > Field Settings > Layout & Print > check “Sort ascending” or “Sort descending” and choose the field). This applies to the field, but note that refreshing may still override if the source data changes.
- Sorting by values when columns are grouped: If you have grouped columns (e.g., dates grouped by month), sorting may only work within the group. You may need to ungroup temporarily or sort using the group header.
- Custom sort order not working: If you use a custom list (e.g., for weekdays), ensure the list is defined in Excel’s Options > Advanced > Edit Custom Lists. The custom list must match the exact text in your column labels.
Alternatives to Manual Sorting
If you find yourself sorting frequently, consider these alternatives:
- Sort the source data: Sorting the data in the original worksheet before creating the pivot table can set a default order, but this is not always reliable because pivot tables may still sort alphabetically by default.
- Use a calculated field: Create a calculated field that ranks items (e.g., using
=RANK()or=LARGE()) and then sort by that field’s values. - Use a PivotChart: Sorting columns in a pivot chart often mirrors the pivot table sort, but you can also sort the chart’s category axis independently in some cases.
- Use Excel’s SORT function (for dynamic arrays): If you’re using Excel 365, you can create a dynamic array formula that sorts the pivot table output. For example, with
=SORT(pivotTableRange, columnIndex, -1), but this requires the pivot table to be in a range you can reference.
Sorting in Google Sheets vs. Excel
In Google Sheets, the process is similar: click the drop-down arrow on the column header and choose Sort A→Z or Sort Z→A. To sort by values, right-click a cell in the row you want to use as the sort key and select Sort sheet by column (but that sorts the entire sheet, not just the pivot table). For pivot tables in Google Sheets, you can also use the Sort by option in the pivot table editor (under Rows or Columns) to specify a value field and order. Excel offers more granular control with the More Sort Options dialog, which Google Sheets lacks.
Tips for Choosing the Right Sort Order
Deciding how to sort depends on your goal:
- Chronological data: Sort by date or month in natural order (Jan, Feb, Mar) using a custom list or by ensuring the dates are recognized as dates.
- Ranking: Sort by a value row (like total sales) in descending order to show top performers first.
- Alphabetical: Use A to Z for categorical lists like product names or regions.
- Custom order: For a specific sequence (e.g., low to high priority), use a custom list.
Remember that sorting columns does not affect the underlying data; it only changes the display order in the pivot table.
Frequently Asked Questions
Q: How do I sort pivot table columns by value in Excel?
Right-click a cell in the row that contains the values you want to sort by (e.g., the Grand Total row), choose Sort, then select Sort Largest to Smallest or Sort Smallest to Largest. This reorders the columns based on the numbers in that row.
Q: Why does my pivot table sort reset every time I refresh?
Pivot tables often revert to the default sort order (usually alphabetical or source order) after a refresh. To keep your sort, go to the field settings (right-click the field > Field Settings > Layout & Print) and set a default sort order. However, if the source data changes, the sort may still reset; you may need to reapply the sort after refreshing.
Q: Can I sort pivot table columns by a custom list (like month names)?
Yes. First, define a custom list in Excel (File > Options > Advanced > Edit Custom Lists). Then, in the pivot table, use the drop-down arrow on the column field, select More Sort Options, choose Custom List, and pick your list. The column labels must exactly match the list entries.
Q: How do I sort columns in a pivot table in Google Sheets?
In Google Sheets, click the drop-down arrow on the column header and select Sort A→Z or Sort Z→A. To sort by values, you can right-click a cell in the row you want to sort by and choose Sort sheet by column, but this sorts the entire sheet. For pivot tables, use the pivot table editor: under Columns, click “Add field” and then set the “Sort by” option to a value field and choose the order.
Q: What is the difference between sorting by label and sorting by value?
Sorting by label reorders columns alphabetically or by custom list based on the column header text. Sorting by value reorders columns based on the numeric values in a specific row (e.g., total sales). Label sorting is organizational; value sorting is analytical.
Q: Can I sort pivot table columns in Excel for the web?
Yes, but with limited options. In Excel for the web, you can click the drop-down arrow on the column field and choose Sort A to Z or Sort Z to A for labels. To sort by values, you may need to use the field settings in the PivotTable Fields pane (if available) or sort the underlying data. The full More Sort Options dialog is not available in the web version.
Related
- Google Sheets Percentage Format: How to Use It
- How to Generate Random Numbers on a Calculator
- Maximum Data Entry: Definition, Limits, and Real Usage
Try it: the Percentage Formula Generator: percent of, percent change, increase and decrease, with the formula.
More in Charts & pivot tables
- Edit a Pivot Table in Google Sheets: Steps and TipsTo edit a pivot table in Google Sheets, click any cell inside it to open the Pivot table…
- Edit Pivot Table Range: 4 Quick WaysTo edit a pivot table range in Excel, select the pivot table, go to PivotTable Analyze > Change…
- Radar Chart in Excel: How to Create and Format OneTo make a radar chart in Excel for Microsoft 365 on Windows, arrange your categories in the first…
- Sample Pareto Chart in Excel: Example, Steps, TipsTo make a sample Pareto chart in Excel, first sort category counts from largest to smallest, calculate each…
- Chart Area in Excel: Definition and How It WorksIn Excel, the chart area is the entire region occupied by a chart, including the plot area and…
- 3D Pie Chart in Excel: How to Create and Format ItTo create a 3-D pie chart in Excel for Microsoft 365 on Windows, select a two-column list of…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.