Locked lesson.
About this lesson
Basic sorting of row and column headers in a PivotTable.
Lesson versions
Multiple versions of this lesson are available, choose the appropriate version for you:
2016, 2019/365.
Exercise files
Download the ‘before’ and ‘after’ Excel workbooks from the video tutorial and try the lesson yourself.
Basic Sorting.xlsx189.5 KB Basic Sorting - Completed.xlsx
190.8 KB
Quick reference
Topic
Basic sorting of row and column headers in a PivotTable.
Where/when to use the technique
When you’d like to control the order items are displayed in a PivotTable.
Instructions
Sorting based on row labels
- Right click one of the labels you wish to sort by > Sort
- Choose the order you’d like to sort by:
- Z at the top: Choose Sort Largest to Smallest
- A at the top: Choose Sort Smallest to Largest
- The sort will be applied to all fields that are part of that row label
- Subsequent sorts can be applied to sort within subtotals
Sorting based on column labels
- Right click one of the labels you wish to sort by > Sort
- Choose the order you’d like to sort by:
- Z on the left: Choose Sort Largest to Smallest
- A on the left: Choose Sort Smallest to Largest
- The sort will be applied to all fields that are part of that row label
- Subsequent sorts can be applied to sort within subtotals
Manual sorting
- Drag the row/column fields into the order you’d like to see them
- Be aware that this turns automatic sorting off for that label level (only)
Restoring Automatic Sorting
- Right click the label field that is in manual mode > Sort > More Sort Options
- Change the manual sort to Ascending/Descending as appropriate
- Click OK
- 00:04 In this video we're gonna look at the basic sorting of row and
- 00:07 column headers in a pivot table.
- 00:10 You'll notice I've got a very simple pivot showing here.
- 00:13 It's got weeks across the top, and it's got sales dollars across the values area.
- 00:17 But it doesn't have any row labels on it whatsoever.
- 00:20 So, what I'm gonna do is,
- 00:21 I'm gonna drag class onto the pivot table, and you'll notice that
- 00:25 by default it actually automatically sorts in alphabetical order from top to bottom.
- 00:29 So we start with alcohol and then go with food.
- 00:32 And likewise, if I pull category on, it'll subcategorize it by alcohol and food, and
- 00:37 again it's sorted in alphabetical order.
- 00:40 Well, what if I wanted to change that?
- 00:42 What if I wanted food above alcohol?
- 00:44 Well i can click on alcohol, right click on it, sort, and I can sort from Zed to A.
- 00:51 And that will flip these two things around.
- 00:53 But notice that it didn't change the alphabetical order inside these
- 00:57 subcategories.
- 00:59 What if I wanted to do that?
- 01:00 Instead of clicking on food, I'll click on one of the items inside the subcategory.
- 01:06 Right click, sort, set to A.
- 01:09 And you'll notice that it changes both of them.
- 01:11 The sorting doesn't apply to just a subgroup.
- 01:14 It applies to all subgroups of that level.
- 01:16 So, I'm sorting the category field or
- 01:19 the class field, and that's gonna go throughout the pivot table.
- 01:23 Now, I can do the same thing on column headers.
- 01:26 Right click, sort from largest to smallest.
- 01:31 We'll flip it around so it goes from left to right.
- 01:34 Okay? Now, what if I did want alcohol up here
- 01:37 and I wanted something in a little bit weirder order?
- 01:39 Maybe I wanted draft beer above wine.
- 01:42 Well, if I click on that label I can actually move to the top of the box,
- 01:47 and that cursor changes into this four pointed arrow.
- 01:50 And if I left click and drag, you'll notice that
- 01:53 I get a bar that will allow me to drag and drop it into a custom order.
- 01:57 So now it's not in any alphabetical order whatsoever.
- 02:00 The interesting thing about this, though,
- 02:02 is that this actually changes to a manual sort.
- 02:05 So now when I update the pivot table, this will not re-sort on me here.
- 02:08 The food and the alcohol will always sort into alphabetical order, so
- 02:11 if I added it with a new category that was called, I don't know, beverage or
- 02:16 non alc, it would sort non alc, then food,
- 02:19 then alcohol because I've asked for it descending order.
- 02:21 But it wouldn't change the sort order for anything in the middle here.
- 02:25 So what if I wanna restore that?
- 02:27 Well, what I'm gonna do is right click on this level, because I sorted categories.
- 02:31 Go to sort, more sort options, and that takes me into this
- 02:36 sort category box, category being the filter that I'm actually working with.
- 02:40 And at this point I can restore it.
- 02:43 I can say, you know what, I want to sort this by ascending order or
- 02:46 descending order.
- 02:46 We'll go with ascending, and say okay, it's no longer on manual.
- 02:50 So now when I refresh my pivot tables it will re-sort.
- 02:54 That setting though, is maintained.
- 02:56 That was the category one.
- 02:57 If I wanted to check the class, I would have to go back in there and
- 03:00 do that one separately.
- 03:01 The same is true for the row headings.
- 03:03 So, that's pretty much your options for sorting your row headings and your column
- 03:08 headings is basically ascending, descending or manual, and how to reset it
- 03:12 if you put it into manual mode and need to get it back into automatic mode.
Lesson notes are only available for subscribers.