How SUBTOTAL works
Syntax
=SUBTOTAL(function_number, range1, [range2], ...)function_number- 9 = SUM, 1 = AVERAGE, 2 = COUNT, 3 = COUNTA, 4 = MAX, 5 = MIN. Add 100 (109, 101...) to also ignore rows hidden by hand.
range1, range2...- The cells to calculate.
Example
Invoices are in a filtered table with amounts in D2:D500. You want the average of the rows currently visible.
=SUBTOTAL(101, D2:D500)Filter by client and the average updates to that client's invoices only.
Common mistakes
- Expecting 9 to ignore rows hidden manually (right-click, Hide). Only 109 does that.
- Using SUM under a filtered table and wondering why the total doesn't change.
Questions people ask
What is the difference between SUBTOTAL and AGGREGATE?
AGGREGATE (Excel only) can also ignore error values. SUBTOTAL works in Excel and Google Sheets and is enough for filtered totals.
Practice it above: type the formula in the formula bar and press Enter to check.