Example 1
Sum a column that contains an error
B8 =AGGREGATE(9,6,B2:B6)
Result: 8455
York has not reported, so B4 is #N/A. SUM(B2:B6) would return #N/A. Option 6 steps over the error and adds the other four.
B8 =AGGREGATE(9,6,B2:B6) returns 8455
Runs a calculation such as sum, average, large or median over a range, with options to skip errors, hidden rows and nested subtotals.
Syntax
=AGGREGATE(, , , [ref2], …)
Excel 2010 and later, including Excel for Microsoft 365 and Excel for the web.
Try it
Edit the formula in B8 or change the inputs. The sheet recalculates as you type.
B8 =AGGREGATE(9,6,B2:B6) returns 8455
AGGREGATE does what SUBTOTAL does and more. It offers 19 calculations, including median, large, small and percentiles, and an options argument that lets you ignore error values. That last feature is why people reach for it: a single #N/A in a column turns SUM, AVERAGE and MAX into errors, while AGGREGATE can step over it.
For functions 1 to 13 you give a range or several ranges: =AGGREGATE(9, 6, B2:B9) sums the numbers in B2:B9 and ignores errors, because option 6 means "ignore error values".
For functions 14 to 19 the second reference is a value: =AGGREGATE(14, 6, B2:B9, 2) returns the second-largest number, ignoring errors. In this form the range can be an array expression.
| Option | Ignores | |---|---| | 0 or omitted | nested SUBTOTAL and AGGREGATE | | 1 | also hidden rows | | 2 | also error values | | 3 | hidden rows and error values | | 4 | nothing | | 5 | hidden rows | | 6 | error values | | 7 | hidden rows and error values |
Option 6 is the one you will use most often. Options 0 to 3 skip nested SUBTOTAL and AGGREGATE results, like SUBTOTAL, so a subtotal row won't be counted twice.
Functions 14 to 19 accept array expressions, which makes a conditional largest or smallest value possible without MAXIFS: =AGGREGATE(14, 6, B2:B9/(A2:A9="North"), 1). Dividing by FALSE (0) produces #DIV/0! for every non-North row, and option 6 ignores those errors, leaving the largest North value.
Watch two limits. The reference form, functions 1 to 13, needs a range, not an array. And hidden-row options apply to rows only: hiding a column has no effect.
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.0 or omitted: nested SUBTOTAL and AGGREGATE. 1: also hidden rows. 2: also error values. 3: hidden rows and errors. 4: nothing. 5: hidden rows. 6: error values. 7: hidden rows and error values.B2:B9/(A2:A9="North").2 for the second largest.Each example is a live sheet. Change the inputs or the formula and watch the result.
Example 1
B8 =AGGREGATE(9,6,B2:B6)
Result: 8455
York has not reported, so B4 is #N/A. SUM(B2:B6) would return #N/A. Option 6 steps over the error and adds the other four.
B8 =AGGREGATE(9,6,B2:B6) returns 8455
Example 2
B8 =AGGREGATE(14,6,B2:B6,2)
Result: 2210
Function 14 is LARGE, so the last argument is k. The sorted numbers are 2,430, 2,210, 1,975 and 1,840.
B8 =AGGREGATE(14,6,B2:B6,2) returns 2210
Example 3
B8 =AGGREGATE(5,6,B2:B6)
Result: 1840
Function 5 is MIN. With option 6 the error in B4 is skipped.
B8 =AGGREGATE(5,6,B2:B6) returns 1840
Example 4
B8 =AGGREGATE(14,6,B2:B6/(A2:A6="North"),1)
Result: 200
Dividing by the test turns every non-North row into #DIV/0!. Option 6 ignores those, so LARGE sees only 120, 200 and 95.
B8 =AGGREGATE(14,6,B2:B6/(A2:A6="North"),1) returns 200
Example 5
B8 =AGGREGATE(12,4,B2:B6)
Result: 95
Function 12 is MEDIAN and option 4 ignores nothing. The middle of 50, 80, 95, 120 and 200 is 95.
B8 =AGGREGATE(12,4,B2:B6) returns 95
Solve it in the sheet. Every answer is checked, with hints if you need them.
Task 1 of 2
In B9, total the weekly sales for the branches that have reported. One cell holds an error.
Answer in B9.
B2:B9/(A2:A9="North") only works with functions 14 to 19.#VALUE!.Use `=AGGREGATE(9, 6, B2:B9)`. Function 9 is SUM and option 6 ignores error values. Plain SUM would return the first error it finds.
AGGREGATE has 19 calculations instead of 11, can ignore error values, and accepts array expressions for LARGE, SMALL and percentiles. SUBTOTAL is simpler and works in every Excel version.
It tells AGGREGATE to ignore error values. It doesn't skip hidden rows. Option 7 skips both hidden rows and errors.
Yes. Use function 14 or 15 with an array that divides by the condition, for example `=AGGREGATE(14, 6, B2:B9/(A2:A9="North"), 1)`. In Microsoft 365, MAXIFS and MINIFS are simpler.
It was added in Excel 2010. In Excel 2007 and earlier the formula returns `#NAME?`.
AGGREGATE is taught in Data analysis with formulas, lesson 19: AGGREGATE: ignore errors. Each lesson is a short, graded exercise like the one above.