
Section: Excel & Google Sheets
The AGGREGATE function in Excel runs one of nineteen calculations and can ignore error values, hidden rows or both. =AGGREGATE(9,6,B2:B200) adds a column that contains #N/A and #DIV/0! without returning an error itself. That is the difference between a report that shows a total and one that shows a message. This guide covers the two forms, the nineteen function numbers, the eight options, and the trap in the array form that catches even experienced users. The sample data is made up.
What AGGREGATE does
Microsoft describes AGGREGATE as returning an aggregate in a list or database, with the option to ignore hidden rows and error values. It covers the everyday calculations plus a few that SUBTOTAL does not have, such as median, large, small, percentile and quartile. It also handles arrays without needing Ctrl+Shift+Enter, which makes it useful for filtered calculations that would otherwise need a helper column.
The two forms
- Reference form:
=AGGREGATE(function_num, options, ref1, [ref2], ...), for a plain range of cells. - Array form:
=AGGREGATE(function_num, options, array, [k]), for an array or a calculation.
The array form takes one array argument and an optional k. The function number determines the supported form. Functions 1 through 13 use the reference form; functions 14 through 19 use the array form and require k. A plain range can still be the array input for LARGE or SMALL.

The nineteen functions
The first argument is a code from 1 to 19:
- 1 AVERAGE, 2 COUNT, 3 COUNTA, 4 MAX, 5 MIN, 6 PRODUCT
- 7 STDEV.S, 8 STDEV.P, 9 SUM, 10 VAR.S, 11 VAR.P
- 12 MEDIAN, 13 MODE.SNGL, 14 LARGE, 15 SMALL
- 16 PERCENTILE.INC, 17 QUARTILE.INC, 18 PERCENTILE.EXC, 19 QUARTILE.EXC
Codes 14 to 19 need a second value: the k for LARGE, SMALL and the percentile functions, or the quart for the quartile functions. Microsoft lists that requirement explicitly, and leaving it out is the most common reason a formula looks right and returns an error.
The options
The second argument decides what to skip:
- 0 or omitted: ignore nested SUBTOTAL and AGGREGATE functions only.
- 1: also ignore hidden rows.
- 2: also ignore error values.
- 3: ignore hidden rows, errors and nested aggregates.
- 4: ignore nothing.
- 5: ignore hidden rows.
- 6: ignore error values.
- 7: ignore hidden rows and error values.
In practice, 9 and 6 are the two you will type most: sum the column, skip the errors. Option 3 is the one to use under a filter when the column also contains errors.

Total a column that contains errors
A lookup that found nothing leaves #N/A in the cell, and one division by zero leaves #DIV/0!. SUM returns the same error, so the total is useless. Replace it with =AGGREGATE(9,6,D2:D200) and the numbers add up while the errors are ignored. This is faster than wrapping every formula in IFERROR, and it keeps the errors visible in the cells so you can still see which rows are broken. Our IFERROR guide covers the other approach if you would rather hide them.
Follow a filter
With option 3, the total follows the visible rows of a filtered list, exactly as SUBTOTAL does, and it still ignores errors. That combination is the reason AGGREGATE exists. If your column is clean, SUBTOTAL is simpler and reads better; if it is not, AGGREGATE saves the cleanup step.
Find the largest visible value
Codes 14 and 15 need the k value: =AGGREGATE(14,3,E2:E200,1) returns the largest value among the visible rows, and changing the 1 to 2 returns the second largest. With option 3, hidden and filtered rows drop out first, so the answer changes as the filter changes. That is a live ranking inside a filtered report, which is hard to do any other way without a helper column.

The array form trap
Microsoft adds a warning that matters: AGGREGATE will not ignore hidden rows, nested subtotals or nested aggregates when the array argument includes a calculation. The example on the page is =AGGREGATE(14,3,A1:A100*(A1:A100>0),1). The multiplication makes it an array expression, and the hidden row option stops applying. If the result ignores your filter, that is almost always the cause. Move the condition into a helper column, or restructure so the array argument is a plain range.
AGGREGATE compared with SUBTOTAL
SUBTOTAL has eleven functions and no error handling. AGGREGATE has nineteen and can skip errors. Both ignore filtered rows, and both can ignore manually hidden rows depending on the option or the 100 series. For a clean table, SUBTOTAL is shorter and more familiar to readers. For a messy one, or when you need median or percentile under a filter, AGGREGATE is the only one of the two that can do it.

Errors and fixes
- #VALUE! The function number is outside 1 to 19, or the option is outside 0 to 7.
- #NUM! on codes 14 to 19. The k or quart argument is missing or out of range.
- Hidden rows still count. The option is 0, 2, 4 or 6, or the array argument contains a calculation.
- Errors still break the total. The option does not include the ignore errors behaviour. Use 2, 3, 6 or 7.
- Numbers are omitted. The column may hold numeric text rather than numbers. Check the source types before aggregation. The FILTER guide covers selecting source rows, not a replacement for type conversion.
Questions and answers
Does AGGREGATE ignore filtered rows?
Yes, with the options that include hidden rows, and it always ignores rows removed by a filter when you use the reference form on a filtered list.
Can AGGREGATE replace SUMIFS?
It has no dedicated criteria argument. Advanced array expressions can implement conditions but have visibility caveats. For ordinary conditional counts or sums, use COUNTIFS or SUMIFS for conditions, or filter the list first.
Why does AGGREGATE give a different answer from SUBTOTAL?
Different option or function number, or an array expression that stopped the hidden row handling.
Does it work in Google Sheets?
No. Google Sheets has SUBTOTAL but not AGGREGATE, so a sheet that moves between the two needs a different approach.
Is AGGREGATE slower than SUM?
Performance depends on the data and formula construction. Compare calculation time on your own workbook rather than assuming a fixed speed difference.
