Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Excel Tutorial
  • Excel Formulas
  • Excel Shortcut Keys
  • Data Analysis in Excel
  • Formatting in Excel
  • Excel Workbooks
  • Statistical Functions
  • Data Visualization in Excel
  • Pivot Tables in Excel
  • MS Excel Quiz
  • Excel Interview Questions
  • Advance Excel
Open In App
Next Article:
How to Sort a Pivot Table in Excel : A Complete Guide
Next article icon

How to Sort a Pivot Table in Excel : A Complete Guide

Last Updated : 23 Dec, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Sorting a Pivot Table in Excel is a powerful way to organize and analyze data effectively. Whether you want to sort alphabetically, numerically, or apply a custom sort in Excel, mastering this feature allows you to extract meaningful insights quickly. This guide walks you through various Pivot Table sorting tutorials, including advanced options and practical examples, ensuring you can manage your data with precision and ease.

Table of Content

  • Types of Sorting in Pivot Tables
  • How to Sort a Pivot Table in Excel: Step-by-Step Guide
  • Advanced Sorting Options in Pivot Table
  • Practical Examples of Sorting in Pivot Tables
  • Common Issues and Troubleshooting
  • Tips for Effective Sorting in Pivot Tables

Types of Sorting in Pivot Tables

  1. Label Sorting: Sort row or column labels alphabetically or in reverse alphabetical order.
  2. Value Sorting: Sort data based on numerical values, such as totals or averages, in ascending or descending order.
  3. Custom Sorting: Arrange data in a specific order, such as months, days of the week, or a custom-defined sequence.

How to Sort a Pivot Table in Excel: Step-by-Step Guide

Follow the below steps to learn how to sort a Pivot Table in Excel:

Step 1: Open MS Excel Sheet

Open an Excel spreadsheet containing a Pivot Table. Ensure the Pivot Table is correctly created from a clean and organized dataset.

image-
Open MS Excel in which you have Pivot Table

Step 2: Sorting by Row or Column Labels

  • Click on the drop-down arrow next to the Row Labels or Column Labels heading in the Pivot Table.
  • From the drop-down menu, choose:
    • Sort A to Z for ascending alphabetical order.
    • Sort Z to A for descending alphabetical order.
image
Sort Row Labels

Step 3: Sort Values

  • Right-click on any value within the Pivot Table.
  • Select Sort, and then choose:
    • Sort Smallest to Largest for ascending order.
    • Sort Largest to Smallest for descending order.
image
Right- Click and Select Sort Option

Step 4: Sort Using the Field List

  • Open the PivotTable Field List by clicking anywhere inside the Pivot Table.
  • Rearrange the fields in the Rows or Columns area to change the sorting order.
image
Rearrange the Field in Rows and Columns

Step 5: Custom Sorting

  • Highlight the Pivot Table or relevant section. (Here we have highlighted Column D).
  • Go to the Data tab on the ribbon and select Sort.

Note: Pivot Tables are linked to the source data, so modifications should always be done through the PivotTable Field List or by updating the source data.

image
Highlight the Column >>Go to the Data Tab>> Click on Sort Option

Set the Field to Sort By

In the Sort dialog box:

  • From the Sort by dropdown menu, choose the field or column that you want to sort. For example, if you’re sorting by months, select the "Month" field.
  • Choose Custom List for Sorting Order
  • Under the Order section, click the dropdown menu and select Custom List.

A new window, Custom Lists, will appear. This allows you to define the sequence in which data should be arranged.

image
Under the Order Select "Custom List"

Define Your Custom Sequence

If the sequence you want is already available in the predefined lists (e.g., "Sunday, Monday, Tuesday, ..." or "January, February, March, ..."), select it. Here we have Selected "January, February, March.."

If your desired sequence is not listed:

Enter your sequence manually, separated by commas. For example:

  • High, Medium, Low (for priority levels).
  • Silver, Gold, Platinum (for membership tiers).
  • Q1, Q2, Q3, Q4 (for fiscal quarters).

Click OK to save the custom sequence. Click Add in the Custom Lists window.


image
Select your Sequence >> Press OK

Apply the Custom Sort Order

  • Once your custom list is selected or created, click OK in the Custom Lists window to return to the Sort dialog box.
  • Click OK again in the Sort dialog box to apply the custom sorting to your Pivot Table.
image
Custom Sorting Applied

Note: Sometimes you might get error message, "We can't make this change for the selected cells because it will affect a PivotTable", occurs because Excel restricts direct modifications to the data layout or structure of a Pivot Table. Sorting, filtering, or modifying the Pivot Table should be done using the built-in PivotTable Field List or the associated menus, not by directly editing cells.

Advanced Sorting Options in Pivot Table

1. Sort by a Specific Field

To sort rows or columns based on a specific value field:

  • Click the drop-down menu in the Row or Column Labels.
  • Select More Sort Options.
  • Choose Ascending (A to Z) or Descending (Z to A).
  • Select the value field to sort by, such as "Total Sales" or "Average Profit."

2. Sort Manually

  • Drag and drop row or column labels directly within the Pivot Table to rearrange them manually.

3. Using Slicers for Sorting

  • Add a slicer to filter and sort data dynamically.
  • Insert a slicer by clicking on the Pivot Table, going to the Insert tab, and selecting Slicer.
  • Use the slicer buttons to sort or filter data interactively.

Common Issues and Troubleshooting

Incorrect Sorting

  • Ensure no blank rows or inconsistent data in the source dataset.
  • Check if the field used for sorting is numeric or text-based, as Excel treats these differently.

Dynamic Data Updates

  • If the source data changes, refresh the Pivot Table to reflect updated sorting.

Custom Lists Not Working

  • Verify that the custom list is correctly defined in Excel’s options.
  • Go to File > Options > Advanced > General > Edit Custom Lists to manage sequences

Tips for Effective Sorting in Pivot Tables

  • Plan the Layout: Design your Pivot Table structure before sorting to avoid repetitive adjustments.
  • Combine Sorting with Filtering: Use filters to focus on specific subsets of data while keeping it sorted.
  • Visualize Sorted Data: Pair your sorted Pivot Table with a Pivot Chart for a clearer representation of patterns.
  • Save Custom Views: Save different sorted views using Excel’s Custom Views feature to quickly switch between analyses.

Conclusion

Sorting a Pivot Table in Excel is essential for efficient data organization and analysis. By learning the basics and exploring advanced techniques, such as custom sort in Excel, you can enhance your ability to present data in a structured and meaningful way. Use these methods to optimize your workflow and resolve common issues, making your Pivot Table insights more impactful.

Also Read

  • How to Refresh a Pivot Table
  • How to Remove Pivot Table But Keep Data in Excel
  • Pivot Table Conditional Formatting in Excel

Next Article
How to Sort a Pivot Table in Excel : A Complete Guide

R

romy421kumari
Improve
Article Tags :
  • Excel
  • ExcelGuide

Similar Reads

    How to Prevent Grouped Dates In Excel Pivot Table?
    We may group dates, numbers, and text fields in a pivot table. Organize dates, for instance, by year and month. In a pivot table field, text elements can be manually selected. The selected things can then be grouped. This enables you to rapidly view the subtotals in your pivot table for a certain gr
    3 min read
    Top Excel Pivot Table Shortcuts Keys: Complete List
    Mastering Pivot Tables in Excel can significantly enhance your data analysis and reporting capabilities. To make the process even faster and more efficient, learning the top Excel Pivot Table shortcut keys is a must. These shortcuts save time, streamline tasks, and allow you to quickly create, modif
    10 min read
    How to Add a Calculated Field to a Pivot Table in Excel
    A Calculated Field in Pivot Table allows you to perform custom calculations within your Excel Pivot Table, giving you more flexibility and deeper insights into your data. Whether you need to add a custom formula, modify existing calculations, or remove a field, this guide walks you through the essen
    6 min read
    How to Create a Power PivotTable in Excel?
    When we have to compare the data (such as name/product/items, etc.) between any of the columns in excel then we can easily do with the help of Pivot table and pivot charts. But it fails when it comes to comparing those data which are in two different datasets, at that time Power Pivot comes into rol
    4 min read
    How to Add a Column in Excel: Step-by-Step Guide
    Need to organize your data better in Excel but unsure how to add a column without disrupting your existing setup? Whether you’re working with a simple list or a complex table, inserting columns is a fundamental skill that increases productivity and keeps your data structured.This guide covers 4 easy
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences