Sub topic 8
Manually Grouping Text Items
This chapter assumes you can build a PivotTable with fields in Rows and Values, and that you know how to use Sum and Count. Dates and numbers group by rule, using a start, an end, and a step. Text has no such order, so you choose which items belong together yourself. This is called manual grouping.
When manual grouping helps
Suppose a sales table has a Region column with these values: North, South, East, West, and Central. Your manager wants two totals, "Coastal" (East and West) and "Inland" (North, South, and Central). The source data has no Coastal column, and you don't need one for a quick report. You can build the groups directly in the PivotTable.
Manual grouping works well for one-off reports and small lists of items. If you need the same grouping again and again, or the list of items is long, a helper column in the source data is easier to maintain. Chapter 11 covers that approach.
Group text items step by step
- Place the text field, for example Region, in Rows. Place a number field, such as Sales, in Values with Sum.
- Click the first item, then hold Ctrl and click each other item that belongs in the same group. For example, click East, then Ctrl+click West.
- Right-click one of the selected items and choose Group. You can also use PivotTable Analyze > Group Selection.
- Excel creates a new field named Region2 and gives the group the name Group1. Your selected items now sit under Group1. The items you did not select stay as they were.
- Select the remaining items (North, South, Central) and choose Group again. Excel names this group Group2.
The table now has two levels. The outer level holds the groups, and the inner level holds the original items.
| Region2 | Region | Sum of Sales |
|---|---|---|
| Group1 | East | 42,000 |
| Group1 | West | 38,000 |
| Group2 | North | 51,000 |
| Group2 | South | 47,000 |
| Group2 | Central | 29,000 |
Rename the groups and clean up the layout
Click the cell that says Group1, type Coastal, and press Enter. Do the same for Group2 and type Inland. Excel updates the label everywhere it appears.
You can also rename the new field. Click the Region2 header and type a better name, such as Area. Each field name in a PivotTable must be unique, so don't reuse a name that already exists.
To see only the group totals, click the minus sign next to a group, or right-click and choose Expand/Collapse > Collapse Entire Field. To remove the original items from view, you can drag the original Region field out of Rows. The group field stays and keeps its totals.
Common errors
- Items not in a group. If you group only some items, the others appear under their own names in the new field. New items that appear later also show up this way. Look for stray labels that match the original names.
- Selecting the wrong cells. Ctrl+click only works on item labels in the same field. If you select a value cell or a header, the Group command is unavailable or groups the wrong thing.
- Grouping a field with a date or number type. If the field holds dates or numbers, the Grouping dialog opens instead of a manual group. To group by hand, select the individual items first.
- Duplicate spellings. "North" and "north " with a trailing space count as different items in some data. Clean the source data first, or your groups will miss some rows.
Removing a manual group
To undo, right-click a group label and choose Ungroup. Excel puts the items back at the top level and removes the group field. If you ungroup just one group, the other group stays in place, so check the layout afterward. The next chapter explains ungrouping and changing groups in more detail.
Exercise
A PivotTable lists the products Pen, Pencil, Marker, Stapler, and Tape in Rows. You want one group named "Writing" with Pen, Pencil, and Marker, and you want Stapler and Tape left as they are. Describe the steps, and say what the new field looks like.
Show answer
Click Pen, Ctrl+click Pencil and Marker, then right-click and choose Group. Excel adds a field named Product2 and puts the three items under Group1. Click the Group1 cell and type Writing. Do not group Stapler and Tape. They appear in Product2 under their own names, Stapler and Tape, because ungrouped items keep their original labels in the new field.
Exercise
You built a manual group in one PivotTable. A colleague creates a new PivotTable from the same source table. Will your groups appear in theirs? Why or why not?
Show answer
No. Manual groups are saved in the PivotTable that you grouped, not in the source data. A new PivotTable starts with no groups. To share the grouping, add a helper column to the source data, such as a Coastal or Inland label per row.