Sort a Pivot Table

HomePivot TableSort a Pivot Table

Sort Based on Values

Let’s sort a very basic pivot table. Here we have wanted to sort the Grand Total from smallest to largest to know the most selling product.

sort-based-on-values
  1. First of all, select any cell in the Grand Total Column and Go to Home tab.
    2-go-to-home-tab
  2. Further, click on Sort and Filter Under Editing.
    3-sort-and-filter-under-editing
  3. After Clicking on the Sort & filter option, a drop-down list will appear.
    4-sort-and-filter-option
  4. Here you will find the required option” Sort Largest to Smallest”. Just a Click away to sort your data.
    5-sort-largest-to-smallest
  5.  Finally, the data is sorted.
    6-sorted-data

Similarly, you can sort the data from smallest to largest value by following the same steps.

  1. To start with, again click on any cell in the total row.
    7-click-any-cell-in-total-row
  2. Now, go to Home → Sort & Filter.
    8-click-sort-and-filter
  3. From here click on Largest to smallest.
    9-sort-largest-to-smallest
  4. The total row is sorted from largest to smallest.
    10-total-row-sorted

Here in the above Pivot table, both the Grand Total columns and rows are sorted from Largest to Smallest value.

Custom Sort a Pivot Table

Imagine, now you need to sort Product Cake from “Smallest to Largest” or vice versa. You can do this using a custom sort option.

  1. Click on any value in the row Cake excluding the Grand Total as we are not sorting the Grand totals.
    11-custom-sort-a-pivot-table
  2. Now click on Home → Sort & Editing.
    12-sort-and-editing
  3. After you click on the drop-down arrow, click on Custom Sort.
    13-click-custom-sort
  4. Here you will get the window “Sort by Value” Opened.
    14-sort-by-value-option
  5. Now select Largest to smallest under Sort Option.
    15-select-largest-to-smallest
  6. Similarly, select the sort direction. Like here we want to sort from left to right, so we will select Left to right.
    16-select-the-sort-direction
  7. Here we go. Now you can easily find out which month had the highest and the lowest sale.
    17-month-wise-sorted-data

Now, what if you need to make a minor change other than the selected pattern in your pivot.

For example, you have sales data from Jan till Dec. Let’s assume you need to bring the current month let’s say August to the top?? This does not fit into any set pattern.

Don’t worry, this is possible. In such cases, you can sort the pivot table manually. Here’s a simple example.

sort-pivot-table-manually

Now in the above table, we have the data organized from Jan till Dec in the Columns and the Countries sorted in alphabetical order. Follow the below steps to bring “Aug” in the first column and “India” in the top row.

  1. First of all, select the header of the column in which you want to move. Like here we want to move the month of Aug. So, we will select the cell Aug.
    19-select-the-header-of-column
  2. Remember we only need to select the header cell.
  3. Now, once you move your cursor on the border of the selected cell, a move object cursor will appear.
    20-select-the-header-cell
  4. After this click on the mouse and drag the column to the position where you want to move. Here we will drag it to the first column.
    21-drag-the-column-to-the-position
  5. Similarly, repeat the steps with the country.
  6. Select “India” and move the cursor on the border to get the move cursor and simply drag it to the first position.
    22-drag-to-first-position

Sort in Alphabetical Order

Now let us sort the countries into alphabetical order for the convenience of our audience. This can be done in two different ways.

sort-in-alphabetical-order
  1. To begin with, click on the top cell “India” in this example.
    24-click-the-top-cell
  2. Now click on the Home tab and go to the Sort & Filter button.
    25-go-to-sort-and-filter
  3. Here click on the option “Sort A To Z”.
    26-sort-a-to-z
  4. The data is sorted. Now you see the countries are sorted in alphabetical order from A to Z.
    27-sorted-data

You can also use the following steps to use another way of sorting in alphabetical order.

  1. Select the Header cell i.e., “Country” in the pivot table.
    28-select-the-header-cell
  2. Now click on the small drop-down arrow next to “Country”.
    29-click-on-drop-down
  3. Now click on the first option i.e., “Sort A to Z”.
    30-sort-a-to-z
  4. Here we go. The countries are sorted in alphabetical order from A to Z.
    31-sorted-data-a-to-z

More on Pivot Table

Refresh a Pivot Table | Pivot Table Keyboard Shortcuts | Delete a Pivot Table | Pivot Table Formatting |Move a Pivot Table | Filter a Pivot Table | Count Unique Values in a Pivot Table | Change Pivot Table Data SourceAdd or Remove Grand Total in a Pivot Table | Add Ranks in Pivot Table | Insert Calculation in Pivot Table | Refresh All Pivot Tables  | Automatically Update a Pivot Table | Running Total in a Pivot Table | Conditional Formatting to a Pivot Table | Pivot Table from Multiple Worksheets | Group Dates in a Pivot Table | Connect a Slicer with Multiple Pivot Tables | Pivot Table Timeline