Pivot Table Sort

Publication Date :

Blog Author :

Download FREE Pivot Table Sort Excel Template and Follow Along!
Pivot Table Sort Excel Template.xlsx

Table Of Contents

arrow

What Is Sorting A Pivot Table In Excel?

Sorting a pivot table in Excel option is available in the "Data" tab, and as the name suggests, we can sort the data in the PivotTables. On the PivotTables, right-click on any data we want to sort, and we will get an option to sort the data as we want. The normal sort option does not apply to PivotTables, and PivotTables are not the normal tables. The sorting done from the PivotTable is known as PivotTable Sort.

Sorting means arranging data or certain items in an order, however desired. It can be in ascending or descending order, sorted by values or ranges. At the same time, a PivotTable is a unique tool to summarize data to form a report.

When we generate data, we can arrange it in ascending or descending order in the PivotTable, just like any other cell range where we can sort the data using the AutoFilter tool.

Key Takeaways

  • PivotTable Sort in the PivotTable is a sorting mechanism. You can sort data in PivotTables by using this sorting option in the "Data" tab or by right-clicking on any data.
  • The normal sort option does not work on PivotTables since they are not normal tables.
  • To sort data in a PivotTable, we'll need to generate a PivotTable first.
  • Sorting arranges data in a specific order based on its type. Numeric data can be sorted in ascending or descending order, while strings can be sorted alphabetically.

How To Sort Pivot Table Data In Excel?

Following are the steps used for sorting PivotTable data in Excel: -

  1. First, create a Pivot Table based on data.
  2. Right-click the value to be sorted in the data and select the desired sorting command.

     

Examples

Example #1

We have data where the quality check department has marked a product "OK" for use and "NOT OK" and "AVERAGE" for use for individual "Product ID." We will build a PivotTable for the data and then find out the highest number of each proportion.

Consider the following data:

Pivot Table sort Example 1
  • The first step is inserting a PivotTable into the data. Then, in the "Insert" tab under the "Tables" section, click on the "PivotTable." A dialog box appears.
Pivot Table sort Example 1-1
  • It asks for the data range. We will select the whole data in this process and click on "OK."
Pivot Table sort Example 1-2

We can add a PivotTable either in a new worksheet or in the same worksheet.

  • In the new worksheet where the excel takes us, we can see the fields section we discussed earlier. Drag "Condition" in the "Rows" and "Product ID" in the "Values" field.
Pivot Table sort Example 1-3
  • We can see on the left that the report has been created for the PivotTable.
Pivot Table sort Example 1-4
  • For the current example, we will sort the data in ascending order. Right-click on the "Count of Product ID" column. A dialog box appears.
Pivot Table sort Example 1-5
  • When we click on "Sort," another section appears. For example, we will click on " Sort Smallest to Largest."
Pivot Table sort Example 1-6
  • We can see that our data has been sorted in ascending order.
Pivot Table sort Example 1-7

Example #2

We have data for a company for sales done each quarter by certain products for 2018. We will build a PivotTable over the data and sort the data concerning quarters and the highest number of sales done each quarter.

Have a look at the data below,

Pivot Table sort Example 2
  • The first step is the same. We need to insert a PivotTable into the data. In the "Insert" tab under the "Tables" section, click on the "PivotTable." A dialog box appears.
Pivot Table sort Example 1-1
  • As earlier, we need to give it a range. We will select our sales data in the process.
Pivot Table sort Example 2-2
  • When we click "OK," we may see the PivotTable fields. Now, drag "Quarters" in "Columns," "Product" in "Rows," and "Sales" in "Values."
Pivot Table sort Example 2-3
  • We have built up our PivotTable for the current data.
Pivot Table sort Example 2-4
  • Now, we will first sort the quarters. Then, we will click on the "AutoFilter" in the "Column Labels."
Example 2-5
  • A dialog box appears where we can see the option to sort the quarter from A to Z or Z to A.
Example 2-6
  • We can choose either of them as to how we want to display our data.
  • Now, right-click on "Sales." Another dialog box appears.
Example 2-7
  • Whenever our mouse is on the "Sort" option, we can see another section where we select largest to smallest.
Example 2-8
  • Now, we have sorted our data from largest to smallest in terms of sales in our PivotTable.
Example 2-9

Example #3

Consider the below table showing sales in years 2017 and 2018.

Pivot Table Sort - Example 3

Now, we have to create a pivot table by clicking on Insert - Tables - PivotTable.

In the Create PivotTable window, we need to select the Table/Range: of the data we want to create a pivot table for. And then, click OK.

In the PivotTable fields, we need to select the sections which we want to view in our pivot table.

Now, right click on Row Labels more options and we can see Sort options, readily available.

Let’s try both the options. If we sort from oldest to newest, the resulting pivot table appears as shown in the below image.

Example 3 - Pivot Table

If we sort from newest to oldest, the resulting pivot table appears as shown in the below image.

Example 3 - Pivot Table sort

Likewise, we can sort PivotTable in Excel.

Important Things To Note

  • Excel PivotTable Sort is done on a PivotTable. So, we must first generate a PivotTable.
  • Sorting depends on the data. It means if the data is numerical, it can be sorted from highest to smallest or vice versa.
  • If the data is in string format, it may be sorted in A to Z or Z to A.

Frequently Asked Questions (FAQs)

1

How to use pivot table sort by value?

Arrow down filled
2

How do you sort a PivotTable by sum?

Arrow down filled
3

How do I sort a pivot table by month?

Arrow down filled