On its own, the SUBTOTAL function is a quiet powerhouse. In both Excel and Google Sheets it lets you calculate sums, averages, counts, and more that automatically respond to filters and hidden rows. Instead of rewriting SUM or AVERAGE every time you slice your data, you call SUBTOTAL with a function number, like 9 or 109 for SUM, and a range such as A2:A500. Excel even layers this into its Subtotal command so you can insert group-level totals and a grand total in a few clicks.
But in a real business, you do not run SUBTOTAL once. You repeat the same ritual every week: export CRM data, paste it into Excel, clean the columns, set up filters, add SUBTOTAL formulas, double check that hidden rows are treated correctly, and then copy charts into a slide deck. That is where an AI computer agent changes the story. Instead of humans re-building the same filtered views and subtotals, you hand the workflow to an agent that opens the sheet, refreshes data, applies the right SUBTOTAL function numbers, validates results against spot checks, and ships your reports while you are on sales calls. Delegating this to an agent turns a fragile manual habit into a dependable background process.
Before you automate, you need to be confident with the basics. SUBTOTAL works the same conceptually in both tools:
Official references:
In both Excel and Sheets you can swap function_num for different views:
This lets a marketer or agency owner answer questions like: what is the average deal size of visible deals, or the maximum spend in the filtered period, without touching the underlying data.
SUBTOTAL ignores other SUBTOTAL results inside its refs. That means you can safely nest group subtotals and a grand total without inflating your numbers.
Once your formulas are solid, you can reduce repetitive clicks using built-in or low-code tools.
Pros: Zero formula writing once set up, robust for non-technical users. Cons: Less flexible for multi-sheet or cross-file reporting.
Pros: Non-destructive filters, perfect for teams sharing the same sheet. Cons: Still requires you to open the sheet, switch views, and export data manually.
You can have tools like Zapier or Microsoft Power Automate push fresh data into your Sheets or Excel files where SUBTOTAL is already configured:
Pros: Keeps data live without manual copy paste. Cons: Integrations require setup, and logic still lives in scattered spreadsheets.
When your team is running dozens of reports across clients or business units, manual and no-code methods still leave you clicking. An AI computer agent, like one built on Simular Pro, can operate your desktop, browser, Excel, and Google Sheets as if it were a trained analyst.
Imagine your Monday pipeline ritual:
Pros: Fully hands-off, consistent, and transparent; every agent action can be inspected and adjusted. Cons: Requires initial design and testing of the workflow, and runs best on stable report formats.
For agencies juggling many client workbooks:
Pros: Massive leverage for account managers; easy to roll out new clients. Cons: Template changes must be coordinated so the agent scripts stay in sync.
You might prefer to keep humans in the loop:
Pros: Best of both worlds: human judgment with machine execution. Cons: Still requires lightweight review time from your team.
As your reporting load grows, these AI agent patterns turn SUBTOTAL from a handy formula into a backbone of reliable, automated insight delivery across Excel and Google Sheets.
Choosing the correct function_num is the key to using SUBTOTAL effectively. The first decision is what calculation you need: AVERAGE, COUNT, SUM, MAX, and so on. The second decision is whether to include manually hidden rows.
In both Excel and Google Sheets, function numbers 1–11 include manually hidden rows, and 101–111 ignore them. For example:
- 9 or 109 = SUM
- 1 or 101 = AVERAGE
- 2 or 102 = COUNT (numeric)
- 3 or 103 = COUNTA (non-empty)
- 4 or 104 = MAX, 5 or 105 = MIN
If you are using filters to slice data, filtered-out rows are always ignored, regardless of the number range. For dynamic dashboards where users sometimes hide rows, use the 100-series (like 109) so your totals only consider visible data. In Excel, you can see the full list and examples in the official docs: https://support.microsoft.com/en-us/office/subtotal-function-7b027003-f060-4ade-9040-e478765b9939
To subtotal grouped data in Excel without hand-writing every formula, use the built-in Subtotal command, which inserts SUBTOTAL formulas for you.
Step by step:
1) Sort your data by the column you want to group on, such as Region or Salesperson (Data > Sort A to Z or Z to A).
2) Click any cell in the data range.
3) Go to Data > Subtotal.
4) In At each change in, choose the grouping column (for example, Region).
5) In Use function, pick the summary you need, such as Sum or Average.
6) In Add subtotal to, tick the numeric columns to summarise, like Sales.
7) Click OK. Excel inserts subtotal rows after each group change and a grand total at the bottom, all implemented with SUBTOTAL formulas.
You can then collapse or expand detail using the outline buttons on the left. The full guide from Microsoft is here: https://support.microsoft.com/en-us/office/insert-subtotals-in-a-list-of-data-in-a-worksheet-7881d256-b4fa-4f81-b71e-b0a3d4a52b3a
In Google Sheets, SUBTOTAL is designed to work hand-in-hand with filters. It automatically ignores rows hidden by a filter, so you can build interactive reports without recalculating formulas.
Here is how to set it up:
1) Arrange your data with headers in row 1 and values below, for example amounts in C2:C1000.
2) Select the header row and choose Data > Create a filter.
3) In a summary cell, enter a formula like =SUBTOTAL(109, C2:C1000). The 109 code tells Sheets to SUM while ignoring manually hidden rows.
4) Click the filter icons in your header to filter by campaign, status, or owner. The SUBTOTAL result updates instantly to reflect only visible rows.
You can switch to a different function by changing 109 to 101 for AVERAGE, 102 for COUNT, 104 for MAX, etc. Google’s official reference for SUBTOTAL, including all function numbers, is here: https://support.google.com/docs/answer/3093649?hl=en
SUBTOTAL behaves differently depending on how rows are hidden and which function number you use. Understanding this logic prevents nasty surprises in your reports.
There are three key rules:
1) Filtered-out rows are always ignored. If you hide rows via a filter in Excel or Sheets, SUBTOTAL will not include them in its calculation, no matter which function_num you use.
2) Manually hidden rows are optional. If you right-click a row and choose Hide, then:
- Function numbers 1–11 will include those hidden rows.
- Function numbers 101–111 will exclude those hidden rows.
3) SUBTOTAL is column-oriented. It is designed for vertical ranges like B2:B500. Hiding columns in a horizontal range may not behave as you expect, especially in Excel.
If you see unexpected numbers, check whether rows are filtered or manually hidden, and confirm that you chose the right function range (1–11 vs 101–111). The Microsoft docs explain these nuances in detail: https://support.microsoft.com/en-us/office/subtotal-function-7b027003-f060-4ade-9040-e478765b9939
To automate recurring SUBTOTAL-based reports at scale, combine solid spreadsheet design with automation layers.
This layered approach lets you run many client or department reports reliably, without humans rebuilding the same SUBTOTAL workflows every week.