Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING HTML & CSS BASH RUST TOOLS

Excel Tutorial

Excel HOME Excel Introduction Excel Get Started Excel Overview Excel Syntax Excel Ranges Excel Fill Excel Move Cells Excel Add Cells Excel Delete Cells Excel Undo Redo Excel Formulas Excel Relative Reference Excel Absolute Reference Excel Arithmetic Operators Excel Parentheses Excel Functions

Excel Formatting

Excel Formatting Excel Format Painter Excel Format Colors Excel Format Fonts Excel Format Borders Excel Format Numbers Excel Format Grids Excel Format Settings

Excel Data Analysis

Excel Sort Excel Filter Excel Tables Excel Conditional Format Excel Highlight Cell Rules Excel Top Bottom Rules Excel Data Bars Excel Color Scales Excel Icon Sets Excel Manage Rules (CF) Excel Charts

Excel PivotTables

Excel PivotTable Intro Excel Create PivotTable Excel PivotTable Values Excel PivotTable Filter Excel PivotTable Group Excel Calculated Field Excel PivotChart

Excel Case

Case: Poke Mart Case: Poke Mart, Styling

Excel Functions

AND AVERAGE AVERAGEIF AVERAGEIFS CONCAT COUNT COUNTA COUNTBLANK COUNTIF COUNTIFS DATEDIF FILTER HLOOKUP IF IFERROR IFS INDEX INDEX MATCH LEFT LEN LOWER MATCH MAX MEDIAN MID MIN MODE NETWORKDAYS NPV OR PROPER RAND RIGHT ROUND SORT STDEV.P STDEV.S SUBSTITUTE SUM SUMIF SUMIFS SUMPRODUCT TEXTJOIN TODAY TRIM UNIQUE UPPER VLOOKUP XLOOKUP XOR

Excel How To

Convert Time to Seconds Difference Between Times NPV (Net Present Value) Remove Duplicates

Excel Cert

Excel Certificate

Excel Examples

Excel Exercises Excel Syllabus Excel Study Plan Excel Training

Excel References

Excel Keyboard Shortcuts


Excel PivotTable Group


Share

Group Data in a PivotTable

Grouping combines many small items into a few bigger ones.

For example, you can group days into years and quarters, or order sizes into ranges like 1-5 and 6-10.

This chapter uses Poke Mart sales data. Download it to follow along: poke_mart_sales.xlsx

Start with a PivotTable that has Sum of Sales in Values, formatted with a thousands separator, and nothing in Rows or Columns. See Create a PivotTable and PivotTable Values.

Group Dates

The data has orders on 731 different days. One row per day would be far too long to read.

Let's group the dates into years and quarters:

  1. Drag Date to the Rows area
  2. Right-click any date in the PivotTable and choose Group. You can also click PivotTable Analyze > Group Field
  3. The Grouping dialog opens. Under By, click Quarters and Years so that both are selected, and click any other selected item to turn it off
  4. Click OK

The Grouping dialog for a date field, with Quarters and Years selected under By

Note: Recent versions of Excel may group a date field automatically when you add it to Rows. You then see years and extra fields like Quarters in the Rows area, without opening the dialog. You can still open the Grouping dialog to change the grouping.

AB
3Row LabelsSum of Sales
420244,393,200
5Qtr1852,950
6Qtr21,119,400
7Qtr31,223,600
8Qtr41,197,250
920255,023,600
10Qtr1977,950
11Qtr21,197,800
12Qtr31,452,100
13Qtr41,395,750
14Grand Total9,416,800

Each year shows its total, with the four quarters below it.

Sales grew from 2024 to 2025, and the third quarter (Qtr3) was the best quarter in both years.

Click the minus button next to a year to collapse it, and the plus button to expand it again.

Months

Select Months in the Grouping dialog as well, and each quarter gets its months below it: Jan, Feb, Mar and so on.

For example, December 2025 was the best month of 2025, with 634,000 in sales.



Group Numbers

You can also group numbers into ranges. Let's see how big the orders are.

  1. Remove Date from the Rows area
  2. Drag Quantity to the Rows area. Drag it, because checking the box would put it in Values
  3. Drag OrderID to the Values area and change it to Count (see PivotTable Values)

The PivotTable now has one row for each quantity, from 1 to 30. Group them in steps of 5:

  1. Right-click any quantity in the PivotTable and choose Group
  2. Set Starting at to 1, Ending at to 30 and By to 5
  3. Click OK

The Grouping dialog for a number field, with Starting at 1, Ending at 30 and By 5

ABC
3Row LabelsSum of SalesCount of OrderID
41-52,496,9501041
56-103,149,750883
611-151,725,400388
716-201,050,900233
821-25449,20098
926-30544,60097
10Grand Total9,416,8002740

Most orders are small: 1,041 of the 2,740 orders had 5 items or fewer.

But the orders with 6 to 10 items brought in the most sales.


Group Selected Items

You can also make your own groups by picking items.

Say you want to compare Kanto with the two other regions together. Remove Quantity and Count of OrderID, and drag Region to Rows:

AB
3Row LabelsSum of Sales
4Hoenn2,972,000
5Johto3,363,650
6Kanto3,081,150
7Grand Total9,416,800
  1. Click Hoenn (A4)
  2. Hold down Ctrl and click Johto (A5)
  3. Click PivotTable Analyze > Group Selection. You can also right-click and choose Group
AB
3Row LabelsSum of Sales
4Group16,335,650
5Hoenn2,972,000
6Johto3,363,650
7Kanto3,081,150
8Kanto3,081,150
9Grand Total9,416,800

Excel adds a new field, Region2, to the Rows area.

Hoenn and Johto are now in a group called Group1. Kanto was not selected, so it gets a group of its own, also called Kanto.

Give the group a better name: click A4, type Hoenn and Johto, and press Enter.

Then right-click the group and choose Expand/Collapse > Collapse Entire Field to hide the regions inside the groups:

AB
3Row LabelsSum of Sales
4Hoenn and Johto6,335,650
5Kanto3,081,150
6Grand Total9,416,800

Ungroup

To remove a group, click it and choose PivotTable Analyze > Ungroup. You can also right-click it and choose Ungroup.

For grouped dates or numbers, right-click any of the groups and choose Ungroup. This removes the grouping from the whole field.

Note: If Excel says "Cannot group that selection", the field probably has blank cells or text in it. Every cell in a date column must be a real date, and every cell in a number column must be a number.


Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.