Function · Math

Excel AGGREGATE function

The Excel AGGREGATE function works like SUBTOTAL and can ignore errors. With one bill replaced by #N/A, option 6 still sums the other three to $327.90. SUM of that range is #N/A.

Excel 2010 and later, including Microsoft 365 and Excel for the web. Also in Google Sheets.

Syntax =AGGREGATE(function_num, options, ref1, [ref2], ...)

AGGREGATE
=AGGREGATE(9,6,B2:B5)

Arguments

NameRequiredWhat to pass
function_numRequiredWhich aggregate. 9 is SUM, 1 is AVERAGE, 4 is MAX, 5 is MIN, 14 is LARGE. LARGE needs the k argument form.
optionsRequiredWhat to ignore. 0 ignores nested SUBTOTAL and AGGREGATE. 5 also ignores hidden rows. 6 ignores errors. 7 ignores hidden rows and errors.
ref1RequiredThe range, or the array, to aggregate.
ref2OptionalMore ranges. For LARGE, SMALL, and similar functions, the next argument is k instead.

Examples

Sum the utility bills and skip a #N/A

=AGGREGATE(9,6,B2:B5)

Result $327.90

=AGGREGATE(9,6,B2:B5)B6
Bills
AB
1MonthBill
2Jan143.60
3Feb96.20
4Mar#N/A
5Apr88.10
6Sum, skip errors327.90
A picture of the sheet, not a live calculator. March is a real #N/A, from NA(), not the word.

AGGREGATE is SUBTOTAL with a second switch for errors, and with more functions. Function 9 is still SUM. Option 6 ignores errors and ignores nested AGGREGATE and SUBTOTAL results. January $143.60, February $96.20, a #N/A, and April $88.10 add to $327.90. SUM of that range is #N/A, and so is SUBTOTAL. The option is the reason this one survives.

Option 0 is the nested-subtotal behavior without hiding anything. Option 5 also skips hidden rows. Option 7 skips hidden rows and errors. LARGE is function 14, and then the next argument is k rather than another range. Excel 2007 does not have AGGREGATE. Ignoring an error also hides a broken formula, the same tradeoff as IFERROR. Use it on a list you already trust, not as a way to stop looking at #REF!.