SUBTOTAL 9 includes rows you hid by hand; 109 leaves them out
Updated
SUBTOTAL(function_num, range) uses function_num for two choices at once. The units digit is the aggregate: 9 is SUM, 1 is AVERAGE, 2 is COUNT, 3 is COUNTA. Adding 100 does not switch SUM to AVERAGE. It switches whether rows you hid with Hide row are included. 9 sums and includes those rows. 109 sums and excludes them. 1 averages and includes them. 101 averages and excludes them. Filtered-out rows are already excluded for every code. Choosing 109 is not what “turns on” a filter.
The filter-versus-hide walkthrough on the same codes is SUBTOTAL hidden rows. Nested SUBTOTAL results dropped from the total are nested SUBTOTAL. Excel’s AGGREGATE option codes are a different table, and Sheets has no AGGREGATE. See AGGREGATE codes. Keep the Google Sheets UI in English. Sheet Error is an independent formula-error library, not a Google product.
Recreate it on a blank sheet
Section titled “Recreate it on a blank sheet”- Open a blank spreadsheet. In A1 type
qty. A25. A315. A425. A535. The plain sum is80. The average is20. Four numeric rows.
Nothing hidden. In C1 type sum9. In C2 enter =SUBTOTAL(9,A2:A5). C2 is 80. In D1 type sum109. In D2 enter =SUBTOTAL(109,A2:A5). D2 is 80. In E1 type avg1. In E2 enter =SUBTOTAL(1,A2:A5). E2 is 20. In F1 type avg101. In F2 enter =SUBTOTAL(101,A2:A5). F2 is 20. Four controls. 109 is not a different statistic from 9 while every row is visible.
Hide one row by hand. Right-click the row header for row 4 (the 25) and choose Hide row. C2 stays 80. Code 9 still adds the hidden 25. D2 becomes 55 (5+15+35). Code 109 skips the row you hid. E2 stays 20 (the average of all four numbers, hidden row included). F2 becomes 18.333…, the average of 5, 15, and 35. The 100 you added changed who is in the aggregate. It did not change SUM into AVERAGE. Leave row 4 hidden.
COUNT uses 2 and 102, not 9. In C4 enter =SUBTOTAL(2,A2:A5). C4 is 4. Code 2 is COUNT, and the 1–11 family includes the manually hidden row, so the hidden 25 is still a number being counted. In D4 enter =SUBTOTAL(102,A2:A5). D4 is 3. People who memorize “9 means subtotal” and then write 109 for a count are still summing. =SUBTOTAL(3,A2:A5) is COUNTA, which on this numeric column matches COUNT. The units digit is the function. The hundreds digit is only the hide switch.
A filter does not split 9 from 109. Unhide row 4. Select A1:A5. Data → Create a filter. Clear 35 in the filter menu. Row 5 drops out because of the filter. C2 and D2 both become 45 (5+15+25). The manual-hide switch did nothing, because nobody used Hide row. =SUM(A2:A5) stays 80. Turn the filter off with Data → Remove filter when you are done reading it. The longer filter story is SUBTOTAL hidden rows.
Leave row 4 hidden again if you want C2 at 80 and D2 at 55 while you read the codes.
What is actually wrong
Section titled “What is actually wrong”function_num9and109are the same aggregate. Both are SUM. The same pairing is1/101AVERAGE,2/102COUNT,3/103COUNTA,4/104MAX,5/105MIN. The added100is “exclude rows hidden with Hide row.”- A cheat sheet that lists only
1through11is not wrong about the aggregate. It is incomplete about manual hides. A report that still includes a row you collapsed for printing is code9(or1, or2) doing what that family does. - Filters are outside this switch. Both families skip filtered rows. If
9and109match while a filter is on, that match is expected. Hide a row by hand to see them diverge. SUMandAVERAGEignore the codes, the filter, and the manual hide. ReplacingSUBTOTALwithSUMto “simplify” puts the hidden25back into the total.- Another
SUBTOTALsitting inside the range is ignored by every code. That is nested SUBTOTAL, not the100switch. A total that looks short with nothing hidden is often a nested subtotal, not a hidden row.
This is not Excel AGGREGATE, where a second argument chooses errors and hidden rows from a different list. See AGGREGATE codes. In Google Sheets that function is #NAME?.
Leave the hidden-row contrast in place: C2 is 80, D2 is 55.
Pick the aggregate, then add 100 only if Hide row should drop out. For a printed view that hides detail rows, use 109 for the sum and 101 for the average. For a total that must include rows a colleague hid while leaving a filter honored, use 9 or 1. Write the code you mean next to the label (sum, ignore manual hides) so the next edit does not “correct” 109 back to 9.
Do not encode the aggregate in the hundreds digit. 101 is not “SUM, but stricter.” It is AVERAGE without manually hidden rows. If D2 was supposed to be a count of visible numbers, the code is 102, and on this sheet that count is 3 while row 4 stays hidden.
If 9 and 109 are equal, no row in the range is manually hidden. Look at the filter, or at a nested SUBTOTAL, before you change the code. If they differ by exactly the cells you hid with Hide row, the codes are working, and the one that matches the report is the one to keep.