Sub topic 10
Grouping Rows in a Google Sheets Table
Assume you already know how to select cells, sort and filter data, and use basic formulas such as SUM. This chapter shows how to group related rows so you can collapse or expand them without deleting or changing the data.
What row grouping does
Row grouping adds an outline control beside the row numbers. You can use the control to hide a set of adjacent rows and show them again later.
Grouping changes the view of the sheet. It does not:
- Delete the grouped rows.
- Filter rows from calculations.
- Combine rows into one record.
- Create a summary or subtotal automatically.
- Change the table's column values.
For example, you might group all orders for one month, all tasks for a project phase, or all detail rows below a subtotal.
A table is useful for organizing the records. Row grouping is useful for hiding or showing sections of those records.
Prepare rows for grouping
Grouping works best when related rows are next to one another. Sort the table before grouping if necessary.
For example, suppose an Orders table contains these columns:
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 | TRUEIf you want to group orders by customer, sort the table by the Customer column. Each customer's rows should form a continuous block. Do not group rows based only on their current position if later sorting will separate them.
Select complete table rows when possible. Selecting only cells inside a table can make the result harder to understand because the row group applies to sheet rows, not just to the selected table cells.
Create and use a row group
- Select the row numbers for the adjacent rows you want to group.
- Right-click the selected row numbers.
- Choose Group rows from the context menu.
- Look for the minus or plus control beside the row numbers.
- Click the minus control to collapse the group.
- Click the plus control to expand it again.
A collapsed group hides its rows but leaves an outline marker. This makes it clear that data exists between the visible rows.
You can create several groups. For example, create one group for each project phase. You can also create nested groups by grouping a smaller set of rows inside a larger group. Use nested groups sparingly because several outline levels can become difficult to read.
> callout note > Grouping is a display feature. A collapsed row still exists, so formulas such as SUM can still include it. Use a filter, a filtered view, or a different formula when you need to exclude rows from a calculation.
Grouping after sorting and filtering
Sorting changes the order of records. Filtering hides records that do not match a condition. Grouping hides a selected block of physical sheet rows.
These features can be used together, but they act differently:
| Feature | Main purpose | What happens to data |
|---|---|---|
| Sort | Reorder records | Records move to a new order |
| Filter | Show matching records | Nonmatching records are hidden |
| Group rows | Collapse a section | Selected rows are hidden behind an outline |
If you group rows and then sort the table, the rows may move. The group can then represent a different category than you intended. Sort first, then create the groups. After changing the sort order, review or recreate groups if needed.
Add summaries for grouped data
Grouping does not calculate totals. Add a subtotal row outside the detail group or use a formula on another sheet.
For a named table called Orders, a table-column formula can summarize a category:
=SUMIF(Orders[Customer], "Acme", Orders[Amount])This formula sums the Amount values where the Customer value is Acme. The result remains visible even when the related detail rows are collapsed.
If you need several levels of summaries, a pivot table is often a better choice. A pivot table groups records logically and calculates totals, counts, or averages. Manual row groups are better when you want to preserve a particular report layout.
Remove a group
To remove grouping while keeping the data:
- Expand the group if you want to inspect it.
- Select the grouped row numbers.
- Right-click the selection.
- Choose Ungroup rows.
Ungrouping removes the outline control. It does not delete the rows or convert the table back to a plain range.
Exercise
You grouped rows 5 through 12, then sorted the table by a different column. What should you check?
Show answer
Check whether rows 5 through 12 still represent the intended category. Sorting can move records, so recreate or adjust the groups if necessary.