Sorting in Excel PivotTables

Mynda Treacy

June 5, 2014

My second Excel love is PivotTables (VLOOKUP is still my number 1).

PivotTables make short work of summarising data and if you change your mind like the wind you can easily satisfy those whims with little more than a drag and a drop, unlike formulas which often require a lot more cajoling.

Once you have your data all Pivoted you might like to experiment with sorting, so here we have a few options ranging from Plain Vanilla, DIY and Bespoke.

Sort A to Z - Plain Vanilla

You can sort by the row labels, column labels or the values area. A simple right-click on any of these areas reveals the sort options:

Select a cell in the row or column label area > right click > Sort > A to Z or Z to A:

sort pivot table a to z

Select a cell in the Values area > right click > Sort > Smallest to Largest or Largest to Smallest:

sort pivot table a to z

Manual Sort Order - DIY

If you just want to manually sort the items, maybe you don’t have many labels to rearrange, then you can left click and drag them into place:

  1. Select the row label you want to move
  2. Hover your mouse over the outer edge of the cell until your mouse pointer changes to the 4-headed arrow (this can be tricky)
  3. Left click and drag it into place:

Here is an animation of manual sorting:

manually sort pivot table

The other way to manually sort is to type over an existing label with the one you want and watch the remaining labels rearrange themselves:

type in sort order for a pivot table

Note: You must type in a label that exists in the PivotTable source data, you can’t go making stuff up 😉

Enter your email address below to download the sample workbook.

By submitting your email address you agree that we can email you our Excel newsletter.

Custom Sort Order - Bespoke

Lastly we can set up a custom sort order with the help of a Custom List. It requires a bit of setup so maybe only do this if you’re going to be performing this sort regularly, or you plan on using the Custom List elsewhere (more on that later).

Create a Custom List

To setup our Custom List:

  • Excel 2007: Windows button > Excel Options > Popular > Edit Custom Lists
  • Excel 2010/2013: File tab > Options > Advanced > General > Edit Custom Lists

The image below shows the Excel 2010/2013 Options window where you'll find the 'Edit Custom Lists' button:

Create new Custom List

This will open the Custom List dialog box where you can 1. type in your list or, 2. import them from a range of cells then click ‘Add’ to create the list, then 'OK' when you're done:

Create new Custom List

Custom Sort PivotTable

Now you can use your new Custom List as the basis for your PivotTable sorting.

To do this select the row/column labels you want to sort > right click > Sort > More Sort Options…:

sort with Custom List

Then in the Sort dialog box click on ‘More Options…’:

sort with Custom List

Uncheck the ‘Sort automatically every time the report is updated’ and select your Custom List from the ‘First key sort order’ list:

first key sort order Custom List

Then click OK. This will take you back to the ‘Sort’ dialog box (below) where you need to choose your field from the ‘Ascending (A to Z) by:’ list, in my case I’m sorting by ‘State’:

sort ascending order

Now your PivotTable is sorted using the order of your Custom List.

Custom Lists

Don’t let your Custom List go to waste. You can use them in other Sorting menus, like the one on the Data tab (or when you right-click and select Sort):

sort with Custom List

And you can use it to AutoFill cells too.

Simply type in the first item in your list and then drag the fill handle:

fill handle Custom List

18 thoughts on “Sorting in Excel PivotTables”

  1. the sorting doesn’t always seem to work …
    if I have a PT with applied filters the sort doesn’t work – when the filters are removed they work
    I have tried data model and without data model and I am stumped as to why

    Reply
    • Hi Peter,

      You should still be able to sort with fitlers applied. Can you please share the file and explain the sort you’re trying to do on our Excel Forum and we’ll take a look.

      Kind regards,

      Mynda

      Reply
  2. Download the Excel Workbook and try yourself. Note: this is a .xlsx file please ensure your browser doesn’t change the file extension on download.

    I down load the file but its showing ************* Please help to down load in Excel 2007

    Reply
    • Hi Adam,

      It sounds like the file hasn’t downloaded with the correct .xlsx file extension, as I can download and open it fine. If you check the file name does it have .xlsx on the end?

      If not, please download it again and at the ‘Save as’ screen (or equivalent for your browser) change the file extension to .xlsx.

      Kind regards,

      Mynda

      Reply
  3. Mtnda:

    Thanks for a good tip! I, too, find pivot tables to be an excellent tool, but I didn’t realize sorting could be this easy.

    Reply

Leave a Comment

Current ye@r *