Excel SUBTOTAL Function Guide — Filtered Sum, Average, and Count (101 vs. 109)

Excel SUBTOTAL function

Complete Guide to Filtered Sums, Averages, and Counts with the Excel SUBTOTAL Function (101 vs. 109)

When creating a report, you may want to sum only the rows visible after filtering, but a regular SUM includes hidden values and returns an incorrect result. This guide shows you how to use the Excel SUBTOTAL function to calculate filtered sums, averages, and counts all at once. At the end, you will also learn how to extend this to conditional sums for visible cells only.

Quick Fix

  1. Select the data range and turn on Data > Filter. (Shortcut: Ctrl+Shift+L)
  2. Filter by the criteria you want.
  3. To exclude hidden rows (manually hidden rows), use function numbers 101–111.
    Sum: =SUBTOTAL(109, D2:D999)
    Average: =SUBTOTAL(101, D2:D999)
    Count (numbers): =SUBTOTAL(102, D2:D999)
  4. Convert the range to an Excel table (Ctrl+T) for cleaner structured references:
    =SUBTOTAL(109, [Sales])
  5. SUBTOTAL automatically excludes rows hidden by filtering. To also exclude manually hidden rows, use 101–111.

SUBTOTAL Basics: Filtered Rows and Hidden Rows

Filtered rows: SUBTOTAL excludes rows hidden by AutoFilter from calculations.
Hidden rows (manually hidden): Numbers 1–11 include manually hidden rows, while 101–111 exclude them.
Double-count prevention: SUBTOTAL automatically ignores the results of other SUBTOTAL formulas.

Function Number Table (1–11 vs. 101–111)

FunctionInclude Hidden RowsExclude Hidden Rows
AVERAGE1101
COUNT2102
COUNTA3103
MAX4104
MIN5105
PRODUCT6106
STDEV.S7107
STDEV.P8108
SUM9109
VAR.S10110
VAR.P11111

Why SUBTOTAL Ignores Other SUBTOTAL Results

When you calculate subtotals for report sections and then calculate a grand total, adding the subtotals again would double-count the values. SUBTOTAL automatically excludes the results of other SUBTOTAL formulas to avoid this problem.

Practical Example: Filtered Sales Sums, Averages, and Counts by Category

Sample Data (Copy and Use Directly)

DateCategoryProductQuantityUnit PriceSales
2025-10-01OuterJumper A549000=D2*E2
2025-10-01TopT-Shirt B1219000=D3*E3
2025-10-02BottomPants C839000=D4*E4
2025-10-02OuterJumper D369000=D5*E5
2025-10-03TopT-Shirt E722000=D6*E6
2025-10-03OuterJumper F2129000=D7*E7

After applying AutoFilter to show only Category = Outer:

  • Sum: =SUBTOTAL(109, F2:F999)
  • Average: =SUBTOTAL(101, F2:F999)
  • Count (numbers): =SUBTOTAL(102, F2:F999)

Excel Table (Ctrl+T) + Structured References

When you convert the range to a table (named 매출표), formulas expand automatically.

  • Sum: =SUBTOTAL(109, 매출표[매출])
  • Average: =SUBTOTAL(101, 매출표[매출])
  • Count (numbers): =SUBTOTAL(102, 매출표[매출])

Advanced: Conditional Sums for Visible Cells Only

SUMPRODUCT × SUBTOTAL × OFFSET

=SUMPRODUCT(
  SUBTOTAL(109, OFFSET(F2, ROW(F2:F100)-ROW(F2), 0, 1)),
  --(C2:C100="Outer")
)

OFFSET splits column F into individual rows and passes them to SUBTOTAL. Values are added only for visible rows, then multiplied by the criteria so that only the intersection is totaled.

Dynamic Array (FILTER) Alternative

=SUM(
  FILTER(F2:F100, (SUBTOTAL(103, OFFSET(F2, ROW(F2:F100)-ROW(F2), 0, 1))=1) * (C2:C100="Outer"))
)

Alternatives, Notes, and Checklist

  • Use AGGREGATE for expanded options to ignore errors and handle hidden rows.
  • Choose accurately between 1–11 and 101–111.
  • Be careful when using COUNTA (3/103) with text values.
  • Structured references in Excel tables are recommended.
  • OFFSET is volatile: consider performance and evaluate a PivotTable alternative.
  • Vertical aggregation is recommended; for horizontal aggregation, consider PivotTables or a combination of functions.

Troubleshooting

IssueCauseSolution
The total is incorrect after filteringUsing SUMReplace it with SUBTOTAL(109)
Manually hidden rows are includedUsing function numbers 1–11Switch to function numbers 101–111
Values are added twiceNested SUBTOTAL formulasKeep only the top-level total
Cannot create a visible-cells-only conditional sumTrying to use SUMIFSUse SUMPRODUCT×SUBTOTAL×OFFSET
Calculation is slowOFFSET is volatileConsider a PivotTable/Power Pivot

Wrap-Up & Related Articles

Now that you know the Excel SUBTOTAL function, filtered sums, averages, and counts are easy to calculate. Explore these related articles next:


Additional Resources (Official Documentation) — Microsoft: SUBTOTAL Function, Microsoft: AGGREGATE Function

Leave a Reply

Your email address will not be published. Required fields are marked *