ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Comparisons
  3. SUBTOTAL vs AGGREGATE in Excel: Totals That Skip Rows

SUBTOTAL vs AGGREGATE in Excel: Totals That Skip Rows

By ExcelReady Team·Updated November 3, 2026·8 min read

The short answer

SUBTOTAL and AGGREGATE both total or count only the rows a filter shows. SUBTOTAL is simpler and works in every version, but one error in the range breaks it. AGGREGATE, from Excel 2010, adds an options argument that can skip errors and hidden rows, plus extra functions such as MEDIAN, LARGE and SMALL.

Key takeaways

  • SUBTOTAL(9,range) sums visible rows. AGGREGATE(9,7,range) sums visible rows and skips errors too.
  • SUBTOTAL returns an error if any visible cell has one. AGGREGATE with option 6 or 7 ignores it.
  • AGGREGATE has 19 functions, including MEDIAN, LARGE and SMALL. SUBTOTAL has 11.
  • Filtered rows: SUBTOTAL always skips them. AGGREGATE skips them only with options 1, 3, 5 or 7.
  • Use SUBTOTAL for clean, filtered lists and AGGREGATE when errors are possible or you need LARGE or SMALL.
On this page+
  1. SUBTOTAL vs AGGREGATE at a glance
  2. How SUBTOTAL works
  3. How AGGREGATE works
  4. The same data solved both ways
  5. When to use SUBTOTAL
  6. When to use AGGREGATE
  7. Common mistakes with SUBTOTAL and AGGREGATE
  8. Our recommendation
  9. Practise it

SUBTOTAL vs AGGREGATE comes down to errors and extra functions. Both give totals that skip the rows a filter hides. SUBTOTAL is shorter and works in every version, but a single #N/A or #DIV/0! in the range breaks it. AGGREGATE can ignore errors and offers more calculations, such as MEDIAN, LARGE and SMALL. This guide compares them on the same data, so you can pick the right one for a report or a job test.

SUBTOTAL vs AGGREGATE at a glance#

AGGREGATE is SUBTOTAL with more functions and more control over what to skip.

FeatureSUBTOTALAGGREGATE
Syntax=SUBTOTAL(function_num, ref1, ...)=AGGREGATE(function_num, options, ref1, ...)
Number of functions1119
Extra functionsNoneMEDIAN, MODE.SNGL, LARGE, SMALL, percentiles, quartiles
Rows hidden by a filterAlways skippedSkipped with options 1, 3, 5 or 7
Rows hidden by handSkipped with 101–111Skipped with options 1, 3, 5 or 7
Error values in the rangeReturns the errorSkipped with options 2, 3, 6 or 7
Other SUBTOTALs in the rangeSkippedSkipped with options 0 to 3
Hidden columnsNot skippedNot skipped
Excel versionsAll versionsExcel 2010 and later
Inserted by Excel for youYes: table Total Row, Data > SubtotalNo, you type it

How SUBTOTAL works#

SUBTOTAL runs one of 11 calculations on the visible rows of a range. The first argument is a function number:

Excel formula
=SUBTOTAL(9,C2:C7)

9 means SUM. Other common numbers are 1 (AVERAGE), 2 (COUNT), 3 (COUNTA), 4 (MAX) and 5 (MIN). Add 100 to skip rows you hid by hand as well as filtered rows: =SUBTOTAL(109,C2:C7). SUBTOTAL also ignores other SUBTOTAL formulas inside its range, so group subtotals aren't counted twice.

The SUBTOTAL function guide lists all 11 numbers. For how it compares with a plain SUM, see SUBTOTAL vs SUM.

How AGGREGATE works#

AGGREGATE has the same idea plus a second argument, options, which says what to skip:

Excel formula
=AGGREGATE(function_num, options, ref1, ...)
OptionWhat it skips
0 or omittedNested SUBTOTAL and AGGREGATE formulas
1Hidden rows, nested SUBTOTAL and AGGREGATE
2Error values, nested SUBTOTAL and AGGREGATE
3Hidden rows, errors, nested SUBTOTAL and AGGREGATE
4Nothing
5Hidden rows
6Error values
7Hidden rows and error values

Functions 1 to 13 match SUBTOTAL's list and add 12 (MEDIAN) and 13 (MODE.SNGL). Functions 14 to 19 are LARGE, SMALL, PERCENTILE.INC, QUARTILE.INC, PERCENTILE.EXC and QUARTILE.EXC. They take an extra last argument, k: =AGGREGATE(14,6,C2:C7,2) returns the second-largest value.

Function numbers side by side#

Both functions share the first 11 numbers, so 9 means SUM in either one. Only AGGREGATE has 12 to 19.

NumberCalculationSUBTOTALAGGREGATE
1AVERAGEYes (101 skips hidden)Yes
2COUNTYes (102)Yes
3COUNTAYes (103)Yes
4 / 5MAX / MINYes (104 / 105)Yes
9SUMYes (109)Yes
12 / 13MEDIAN / MODE.SNGLNoYes
14 / 15LARGE / SMALLNoYes, with k
16 to 19Percentiles and quartilesNoYes, with k

In AGGREGATE, the 100-series numbers don't exist. Hidden rows are controlled by the options argument instead.

The same data solved both ways#

Here is a small sales list. Chloe's cell shows #DIV/0! because the formula behind it divides by an empty cell.

ABC
1RegionRepSales
2NorthAna400
3SouthBen250
4NorthChloe#DIV/0!
5EastDev300
6SouthEma150
7NorthFinn500

Task 1: total everything, despite the error#

Excel formula
=SUBTOTAL(9,C2:C7)
=AGGREGATE(9,6,C2:C7)

SUBTOTAL returns #DIV/0!, just like =SUM(C2:C7). AGGREGATE returns 1,600 (400 + 250 + 300 + 150 + 500), because option 6 ignores errors.

Task 2: filter to South#

Filter the Region column to South (rows 3 and 6). Now the error row is hidden:

Excel formula
=SUBTOTAL(9,C2:C7)
=AGGREGATE(9,5,C2:C7)

Both return 400 (250 + 150). SUBTOTAL works again because the cell with the error is no longer visible.

Task 3: filter to North#

Filter to North (rows 2, 4 and 7). Chloe's error is visible again:

Excel formula
=SUBTOTAL(9,C2:C7)
=AGGREGATE(9,7,C2:C7)

SUBTOTAL returns #DIV/0!. AGGREGATE with option 7, which skips hidden rows and errors, returns 900 (400 + 500).

Task 4: the second-largest sale#

SUBTOTAL has no LARGE function, so it can't answer this. With the filter cleared:

Excel formula
=AGGREGATE(14,6,C2:C7,2)

The result is 400: the largest is 500, then 400. Use option 7 instead of 6 to rank only the visible rows.

Task 5: rows hidden by hand#

Clear the filter, then hide row 5 (Dev) by right-clicking its row number and choosing Hide:

Excel formula
=SUBTOTAL(109,C2:C7)
=AGGREGATE(9,7,C2:C7)

SUBTOTAL still returns #DIV/0!, because Chloe's row is visible. AGGREGATE returns 1,300: the 1,600 total minus Dev's 300. With =SUBTOTAL(9,C2:C7) and no error, Dev's 300 would still be counted, because 9 only skips rows hidden by a filter.

When to use SUBTOTAL#

Use SUBTOTAL when the data is clean and you only need totals, counts or averages of visible rows. It fits well when:

  • You filter a list and want the total to match the screen. The guide to summing only visible cells covers this case.
  • You use a table's Total Row or Data > Subtotal. Excel writes SUBTOTAL formulas for you there.
  • The file must open in very old Excel, before 2010.
  • Other people maintain the file. SUBTOTAL is more widely known, and =SUBTOTAL(109,C2:C7) is easy to read.

When to use AGGREGATE#

Use AGGREGATE when errors might appear, or when you need a calculation SUBTOTAL doesn't have. It is the better choice when:

  • The data has errors you can't fix yet, such as #N/A from a lookup on imported data. See how to sum and ignore errors for other approaches.
  • You need MEDIAN, LARGE or SMALL on filtered rows, such as the top sale in the visible region.
  • You need a conditional top value that skips errors. In the array form, =AGGREGATE(14,6,C2:C7/(A2:A7="North"),1) returns the largest North sale, 500. Rows that aren't North become errors when divided by FALSE, and option 6 skips them along with Chloe's #DIV/0!. This form works only with functions 14 to 19.

Common mistakes with SUBTOTAL and AGGREGATE#

Most wrong results come from the function number or the option:

  1. Using AGGREGATE option 6 on a filtered list. Option 6 skips errors but still includes filtered rows. Use 7 to skip both.
  2. Mixing up the arguments. In AGGREGATE, the function number comes first and the option second. =AGGREGATE(6,9,C2:C7) means PRODUCT with an invalid option, and Excel returns #VALUE!.
  3. Using SUBTOTAL 9 after hiding rows by hand. 9 only skips filtered rows. Use 109.
  4. Expecting hidden columns to be skipped. Both functions skip hidden rows only. A horizontal range still includes hidden columns.
  5. Hiding errors you should fix. Skipping a #N/A means that row's value is missing from the total. Check why the error is there.

For the filter steps themselves, see how to filter data in Excel, and for SUBTOTAL's group-total uses, the SUBTOTAL function in Excel.

Our recommendation#

Use SUBTOTAL, usually with 109, for clean lists that people filter: it is short, familiar and built into tables. Switch to AGGREGATE when the range might contain errors, or when you need MEDIAN, LARGE or SMALL on visible rows. On a filtered list with possible errors, =AGGREGATE(9,7,range) is the safest total. And for fixed totals with no filters or errors, a plain SUM is still the simplest choice.

Practise it#

Totals that follow a filter are a common Excel test task. Practise filtering a table in a live spreadsheet: you'll filter by value and condition, then total and count only the visible rows with SUBTOTAL. If you need a refresher first, practise SUM and AutoSum. Every answer is checked the moment you press Enter. Or try the AGGREGATE exercise on this page.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Chloe's sales cell shows #DIV/0!, so =SUM(C2:C7) fails. In F2, use AGGREGATE to sum C2:C7 while ignoring errors: function 9 for SUM, option 6 to ignore errors.

fx
ABCDEFG
1
Region
Rep
Sales
2
North
Ana
400
Total sales
3
South
Ben
250
4
North
Chloe
#DIV/0!
5
East
Dev
300
6
South
Ema
150
7
North
Finn
500
8
9
10

Tip: AGGREGATE takes the function number first (9 is SUM), then the option (6 ignores errors), then the range.

Practise this in a lesson

LessonFilter a tableTurn on filter buttons with Ctrl+Shift+L, filter by one or several values and by a number condition, total and count only the visible rows with SUBTOTAL, then clear the filters.LessonSUM and AutoSumAdd up a column of numbers with SUM, then let AutoSum write the formula for you.Function guideSUBTOTALTotal filtered lists and grouped data without double counting using SUBTOTAL. Function codes 9, 109 and more, plus a live exercise.Function guideSUMAdd up columns, rows and separate ranges with Excel's SUM function. Clear examples, common mistakes and a live practice exercise.

Frequently asked questions

What is the difference between SUBTOTAL and AGGREGATE in Excel?

+

Both calculate on visible rows only. AGGREGATE adds an options argument that can also ignore error values, and it offers 19 functions instead of 11, including MEDIAN, LARGE and SMALL. SUBTOTAL works in every version of Excel, while AGGREGATE needs Excel 2010 or later.

What does AGGREGATE 9 6 mean?

+

In =AGGREGATE(9,6,C2:C7), 9 means SUM and 6 means ignore error values. It adds every number in the range and skips cells such as #N/A or #DIV/0!. It still includes hidden rows.

Does AGGREGATE ignore filtered rows?

+

Only with options 1, 3, 5 or 7. With options 0, 2, 4 or 6, AGGREGATE includes rows hidden by a filter. Use 5 to skip hidden rows, or 7 to skip hidden rows and errors.

Can SUBTOTAL ignore errors?

+

No. If any visible cell in the range contains an error, SUBTOTAL returns that error. Use AGGREGATE with option 6 or 7 instead, or fix the errors at the source.

Is AGGREGATE available in all versions of Excel?

+

AGGREGATE is available in Excel 2010 and later, including Microsoft 365 and Excel for the web. SUBTOTAL works in every version, so use it if the file must open in Excel 2007 or earlier.

Sources

  • AGGREGATE function - Microsoft Support
  • SUBTOTAL function - Microsoft Support
  • Filter data in a range or table - Microsoft Support

Written and checked by the ExcelReady Team. First published November 3, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. SUBTOTAL vs AGGREGATE at a glance
  2. How SUBTOTAL works
  3. How AGGREGATE works
  4. The same data solved both ways
  5. When to use SUBTOTAL
  6. When to use AGGREGATE
  7. Common mistakes with SUBTOTAL and AGGREGATE
  8. Our recommendation
  9. Practise it

Keep reading

Comparisons· 7 min read

SUBTOTAL vs SUM in Excel: Totals That Respect Filters

SUM adds every number in a range, whether rows are filtered, hidden or already totals. SUBTOTAL with 9 adds only the rows a filter leaves visible and skips other SUBTOTAL formulas, so group totals aren't counted twice. SUBTOTAL with 109 also skips rows you hid by hand. Use SUM for fixed totals and SUBTOTAL for lists people filter.

Data tools· 5 min read

SUBTOTAL in Excel: Totals That Ignore Filtered Rows

SUBTOTAL calculates a total that skips rows hidden by a filter: =SUBTOTAL(109,D2:D11) adds only the visible amounts, while SUM adds every row. The first argument picks the calculation: 9 or 109 sums, 1 or 101 averages, 3 or 103 counts non-empty cells. The 100s also skip rows you hid by hand.

Math· 5 min read

How to Sum Only Visible (Filtered) Cells in Excel

To sum only visible cells in Excel, use SUBTOTAL instead of SUM. =SUBTOTAL(9,C2:C8) adds only the rows left showing after you filter. =SUBTOTAL(109,C2:C8) also skips rows you hid by hand. SUM always adds every cell, hidden or not. AGGREGATE(9,5,C2:C8) does the same and can skip error values too.

More on comparisons

  • SUMIF vs COUNTIF: Totals vs Counts
  • SUMIF vs SUMIFS: What's the Difference?
  • SUMPRODUCT vs SUMIFS: Which Should You Use?
  • SWITCH vs IFS in Excel: Which to Use
  • Text to Columns vs TEXTSPLIT in Excel
  • TEXT vs VALUE in Excel: Numbers to Text and Back
All comparisons articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free