Adding subtotals in Google Sheets lets you automatically group and sum data by category, such as total sales per region or expenses per department. This guide shows you the built-in SUBTOTAL function and the Subtotal menu command (available in the Google Sheets desktop version), plus how to handle common pitfalls.
What You’ll Need
- A Google account and a browser (Chrome, Firefox, Edge, or Safari) to open Google Sheets.
- Your data organized in a table with a header row (e.g., Category, Amount).
- For the automatic Subtotal menu, your data must be sorted by the column you want to group by.
Step-by-Step
Method 1: Using the SUBTOTAL Function (Works Everywhere)
- Open your Google Sheet with the data you want to subtotal. For example, assume column A contains categories (e.g., “North”, “South”) and column B contains amounts.
- Decide where to place the subtotal. Typically, you put it below the group of rows you want to sum, or in a separate summary area. For a single group, you can put it at the bottom of the list.
- Click the cell where you want the subtotal to appear (e.g., B10).
- Type the formula:
=SUBTOTAL(9, B2:B9). The first argument 9 means SUM (ignore hidden rows). If you want to include manually hidden rows, use 109 instead. The second argument is the range to sum. Press Enter. - Repeat for each group if you have multiple categories. For example, if rows 2–5 are “North” and rows 6–9 are “South”, place a subtotal after row 5 and another after row 9.
- Add a grand total at the bottom using
=SUBTOTAL(9, B2:B9)(or simply=SUM(B2:B9)). The SUBTOTAL function ignores other SUBTOTAL formulas, so if you use it for the grand total, it won’t double-count the subtotals. - Format the subtotal rows (bold, background color) to make them stand out.
Method 2: Using the Subtotal Menu (Desktop Only)
- Sort your data by the column you want to group by. Select the entire data range (including headers), then go to Data > Sort range. Choose the column (e.g., Column A) and click Sort.
- Select the entire data range (including headers and all rows).
- Go to the menu: Data > Subtotal (this is available in the Google Sheets desktop browser version; it is not in the mobile app or the Sheets web app on some devices).
- In the Subtotal dialog, set:
- At each change in: choose the column you sorted by (e.g., “Category”).
- Use function: choose SUM (or other functions like COUNT, AVERAGE).
- Add subtotal to: check the column(s) you want to sum (e.g., “Amount”).
- Click OK. Google Sheets will insert subtotal rows automatically, with a grand total at the end.
- Collapse/expand groups using the plus/minus icons on the left to hide or show detail rows.
Common Mistakes
- Not sorting before using the Subtotal menu – The menu groups consecutive rows with the same value. If your data is not sorted, you’ll get multiple subtotals for the same category.
- Using SUM instead of SUBTOTAL for grand totals – If you use
=SUM()over a range that already contains SUBTOTAL rows, you’ll double-count. Always use=SUBTOTAL(9, ...)for grand totals. - Incorrect function number – Using
1(AVERAGE) instead of9(SUM) gives averages, not totals. Double-check the first argument. - Including the subtotal row in the range – If you manually add a subtotal and then later extend the range to include it, you’ll get circular references or double counting.
Tips
- Use the SUBTOTAL function for filtered data – It automatically ignores rows hidden by filters, making it perfect for dynamic reports.
- Combine with grouping – After using the Subtotal menu, you can manually group rows (right-click > Group rows) to create collapsible sections.
- Format subtotal rows – Apply bold text and a light background color to make them visually distinct. Use conditional formatting if you want automatic styling.
- Use the function list – The SUBTOTAL function supports 11 operations: AVERAGE (1), COUNT (2), COUNTA (3), MAX (4), MIN (5), PRODUCT (6), STDEV (7), STDEVP (8), SUM (9), VAR (10), VARP (11). Add 100 to ignore hidden rows (e.g., 109 for SUM ignoring hidden rows).
- Keyboard shortcut for inserting a row – To add a blank row above a cell, press Ctrl+Shift+= (Windows) or Cmd+Shift+= (Mac).
Troubleshooting
Subtotal menu is grayed out or not available – This feature is only available in the desktop browser version of Google Sheets, not in the mobile app or the Sheets web app on some devices. Try opening the sheet in a full browser on a computer.
Subtotals appear in the wrong place – If you used the Subtotal menu, ensure your data is sorted by the grouping column. If you used the SUBTOTAL function, check that your range references are correct and that you placed the formula in the intended cell.
Grand total is double-counting – Replace any =SUM() formulas that cover subtotal rows with =SUBTOTAL(9, ...). The SUBTOTAL function ignores other SUBTOTAL formulas, so it will only sum the original data.
Subtotals don’t update when data changes – SUBTOTAL formulas recalculate automatically, but if you manually inserted rows, make sure the range covers the new rows. Also check that you haven’t accidentally set calculation to manual (File > Settings > Calculation).
Frequently Asked Questions
Can I add subtotals on the Google Sheets mobile app? – No, the automatic Subtotal menu is not available on mobile. You can still use the SUBTOTAL function manually on mobile by typing the formula.
What’s the difference between SUBTOTAL(9) and SUBTOTAL(109)? – Both sum, but 109 also ignores rows that are manually hidden (not just filtered). Use 109 when you want to exclude hidden rows from the total.
Can I subtotal by multiple columns at once? – The Subtotal menu only allows one grouping column at a time. For multiple levels, you can run it twice, but it’s easier to use a Pivot Table (Data > Pivot table) for multi-level grouping.
Does SUBTOTAL work with filtered data? – Yes, SUBTOTAL with function numbers 1–11 ignores rows hidden by filters. That’s a key advantage over SUM.
How do I remove subtotals added by the menu? – Select the data range, go to Data > Subtotal, and click Remove all. This deletes the subtotal rows and the outline symbols.
Can I use AVERAGE instead of SUM in subtotals? – Yes, in the Subtotal menu choose AVERAGE in the “Use function” dropdown. With the SUBTOTAL function, use =SUBTOTAL(1, range).
Related
- Select All Windows Command: Full Guide
- Counter Object Python: How It Works & When to Use It
- Google Sheets Count Checkbox: 4 Easy Ways
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- How to Add Page Numbers in Word Starting on Page 2To add page numbers in Word from the second page, insert a page number, then turn on Different…
- How to Delete a Cover Page in WordTo delete a built-in cover page in Word for Microsoft 365 on Windows, select Insert > Pages >…
- Uniform Inventory Spreadsheet: Build a Useful TrackerCreate a uniform inventory spreadsheet in Excel with one row per item and size, columns for opening stock,…
- Balance GraphQL Checklist for Accurate API DesignA balance GraphQL checklist is a practical set of checks for making balance data precise, permission-controlled, consistent, and…
- Excel Cell Phone Accessories in Clementi: What to KnowIf you mean a shop called Excel that sells cell phone accessories in Clementi, I can’t reliably confirm…
- Relative Imports in Python: How They WorkRelative imports in Python let you import a module using a path relative to the current module’s location,…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.