Sub topic 10
Grouping rows in a table
This chapter assumes you can convert a range to a table, rename it, and sort and filter it. It also assumes you can read a structured reference such as Orders[Amount]. The earlier chapters cover those skills.
Grouping gathers table rows that share a value in one column under a collapsible heading. All the Acme orders sit together, then all the Globex orders, and so on. You can collapse a group to a single line or expand it to see every row. Grouping changes how the table is displayed. It does not change the data.
What grouping does and does not do
A group is built from a column. Every distinct value in that column becomes one group, and rows with that value are placed under it. Each group has a heading row that shows the value and, depending on your version, a count of the rows inside it.
Grouping is a view of the table, in the same way that sorting and filtering are. The table keeps the same rows, the same column types, and the same name. Formulas that refer to Orders[Amount] still see every row in the column, including rows inside collapsed groups.
Grouping is easy to confuse with two other features:
| Feature | Where you find it | What it does | Changes the data? |
|---|---|---|---|
| Table group by | The column menu in a table header | Clusters rows under a heading per value and lets you collapse them | No |
| Row grouping | Data menu, Group | Lets you collapse a manually chosen set of rows or columns | No |
| Pivot table | Insert menu, Pivot table | Builds a separate summary in a new range | Creates new output |
Use the table's group by when the grouping should follow the data. Use manual row grouping when you want to hide an arbitrary block of rows. Use a pivot table when you want a compact summary that sits apart from the source rows.
Sample data
The examples use the Orders table from earlier in the tutorial, with a few extra rows so that some customers appear more than once.
Order ID | Customer | Order Date | Amount | Paid
1001 | Acme | 2026-01-05 | 250 | TRUE
1002 | Globex | 2026-01-09 | 480 | FALSE
1003 | Initech | 2026-01-12 | 125 | TRUE
1004 | Acme | 2026-01-15 | 300 | TRUE
1005 | Globex | 2026-01-20 | 150 | TRUE
1006 | Acme | 2026-01-22 | 90 | FALSEGrouping on the Customer column produces three groups. Acme holds three rows, Globex holds two, and Initech holds one.
Applying a group
The exact menu wording changes between releases, so look for the intent rather than the label.
- Click any cell in the table so the table menus appear.
- Open the dropdown arrow in the header of the column you want to group by. For this example, use Customer.
- Choose the group option for that column. It is labelled along the lines of "Group by Customer".
- Check that each distinct customer now has its own heading row with its rows beneath it.
To expand or collapse a single group, use the arrow beside its heading. Most versions also offer a way to expand or collapse every group at once from the same column menu or the table menu.
To remove grouping, open the same column menu and clear the group. The rows return to a single flat list in their normal order.
Choosing a good column to group by
Grouping is useful only when the column has repeated values. A column such as Order ID, where every value is unique, would produce one group per row, which is clutter and no help. Good candidates share these traits:
- Few distinct values compared with the row count. Customer, Region, Status, and Category all work. A table of 500 rows grouped by a column with 8 values gives you 8 manageable groups.
- Consistent spelling. Group matching is by value, so "Acme" and "Acme " (with a trailing space) or "acme" may land in different groups. Dropdown and checkbox column types help here because they limit what can be entered.
- A stable type. Checkbox columns such as Paid group naturally into TRUE and FALSE. Date columns group by each exact date, so a date column with many different days gives many small groups.
Because grouping depends on clean values, the cleanup advice from the earlier chapter on preparing data matters more here than almost anywhere else. Inconsistent entries show up immediately as extra groups.
Grouping together with sorting and filtering
Grouping combines with the other two view tools, but each one has its own job.
- Filtering decides which rows are present. If you filter to unpaid orders, the groups show only unpaid rows, and a customer with no unpaid orders has no group at all.
- Sorting decides the order inside each group. Sort by Order Date ascending and each customer's orders appear oldest first.
- Grouping decides how the remaining rows are clustered.
The order in which you set them up does not matter much, because they are independent settings on the table view. A typical review workflow is to filter Paid to FALSE, group by Customer, and sort by Amount descending. The result shows who owes you money, with each person's largest unpaid invoice at the top of their group.
Group order, meaning the order of the headings themselves, follows the grouped column's values. If the headings are not in the order you want, check the sort setting on the grouping column before assuming something is broken.
Summaries per group
Grouped tables can show a calculated value on the group heading, such as a count of rows, or a sum or average of a numeric column. Availability and wording depend on your version of Sheets, so check the column menu of the Amount column after grouping to see which summaries it offers.
Summaries are useful for quick answers: total billed per customer, or how many unpaid orders each customer has. They are display-only, so you cannot reference a group heading's value from a formula.
When you need a number that other cells can use, write a formula. Structured references keep it readable and let it grow with the table:
=SUMIF(Orders[Customer], "Acme", Orders[Amount])This returns 640 for the sample data, the sum of 250, 300, and 90. A count of Acme's unpaid orders uses the same pattern:
=COUNTIFS(Orders[Customer], "Acme", Orders[Paid], FALSE)This returns 1. Both formulas ignore grouping completely. They read the stored column, so collapsing or expanding a group has no effect on the result.
Adding rows to a grouped table
Table expansion still works when the table is grouped. When you add a row, the new row joins the table, and the table places it under the group that matches its value in the grouped column.
Two behaviors are worth knowing:
- A new value creates a new group. If you type a customer called "Umbrella" in a new row, a fresh Umbrella group appears with one row.
- Editing a grouped value moves the row. Change a row's Customer from "Acme" to "Globex" and it moves to the Globex group. This can feel as if the row vanished if the Acme group was the only place you were looking.
It is often easier to enter new rows while grouping is off, then turn grouping back on to review. Entering data in a grouped view also means the row you are typing in can jump to another group as soon as you commit the grouped column's value.
Common problems
The group option is missing from the column menu. The table menus appear only when a cell in the table is selected. Click inside the table first. Also confirm that the range is actually a table and not a styled range, because a range with banded colors looks similar but has no table menus.
Too many groups. The grouped column has near-unique values. Group by a different column, or add a helper column that buckets the values. For dates, a helper column such as =TEXT(C2, "yyyy-mm") groups orders by month. Add it as a normal column in the table and group by that column.
Groups that should match but do not. This is a data cleanup problem, as described above. Check spacing and capitalization, or move the column to a dropdown type.
A formula result differs from the group summary. Check whether a filter is active. Group summaries describe the rows currently shown, while a plain SUM of a column covers all rows, including those that a filter hides.
Grouping disappeared after converting to a range. This is expected. Grouping belongs to the table. When you convert a table back to a plain range, the group settings are lost, and the data returns to a flat list. Any formulas that used structured references are rewritten to ordinary cell references.
When grouping is the wrong tool
Grouping works well for reading and reviewing a table that you also edit. It is not a reporting tool. Choose another approach in these cases:
- You need a separate summary to share or chart. Use a pivot table, which writes its output to its own range.
- You need totals that other formulas depend on. Use SUMIF, COUNTIFS, or a similar function with structured references.
- You need to collapse an arbitrary set of rows that do not share a value. Use manual row grouping from the Data menu instead.
Exercise
Using the six-row Orders sample, you group by Customer and then filter Paid to FALSE. Which groups do you see, how many rows does each contain, and what does =SUM(Orders[Amount]) return?
Show answer
You see two groups: Globex with one row (order 1002, amount 480) and Acme with one row (order 1006, amount 90). Initech has no unpaid rows, so it has no group. =SUM(Orders[Amount]) still returns 1395, the sum of all six amounts (250 + 480 + 125 + 300 + 150 + 90), because a structured reference reads the whole column and ignores both grouping and filtering.
Exercise
Your table has an Order Date column and you want to review orders month by month. Grouping on Order Date gives one group per day. How do you get one group per month?
Show answer
Add a helper column to the table, for example named Month, with a formula such as =TEXT(C2, "yyyy-mm"). Then group by the Month column. Every order in the same month has the same text value, so all of them fall into the same group.