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.
Syntax =AGGREGATE(function_num, options, ref1, [ref2], ...)
=AGGREGATE(9,6,B2:B5)Arguments
| Name | Required | What to pass |
|---|---|---|
| function_num | Required | Which aggregate. 9 is SUM, 1 is AVERAGE, 4 is MAX, 5 is MIN, 14 is LARGE. LARGE needs the k argument form. |
| options | Required | What to ignore. 0 ignores nested SUBTOTAL and AGGREGATE. 5 also ignores hidden rows. 6 ignores errors. 7 ignores hidden rows and errors. |
| ref1 | Required | The range, or the array, to aggregate. |
| ref2 | Optional | More 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
| A | B | |
|---|---|---|
| 1 | Month | Bill |
| 2 | Jan | 143.60 |
| 3 | Feb | 96.20 |
| 4 | Mar | #N/A |
| 5 | Apr | 88.10 |
| 6 | Sum, skip errors | 327.90 |
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!.