AGGREGATE Function in Microsoft Excel: Syntax, Examples & Compatibility
Learn how to calculate an aggregate while explicitly controlling which errors or hidden rows are ignored in Microsoft Excel. Includes syntax, two verified-by-reasoning results, troubleshooting and portability notes.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: AGGREGATE combines a calculation code with an exclusion option. It can ignore source errors, manually hidden rows or nested totals, but the chosen option and reference-versus-calculated-array form both matter.
Availability and version history
- Introduced: Excel 2010, identified as a new function in Microsoft’s Excel 2010 changes. The first preview build and calendar launch date are not established here.
- Availability: Official help lists Excel for Microsoft 365, Excel for Microsoft 365 for Mac, Excel 2024, Excel 2024 for Mac, Excel 2021, Excel 2021 for Mac, Excel 2019, Excel 2016, Excel Web App.
- Checked: October 14, 2026; official AGGREGATE reference. Documentation check, not a new native test; existing example-verification notes retain their scope.
Two syntax forms
=AGGREGATE(function_num, options, ref1, [ref2], ...)
=AGGREGATE(function_num, options, array, [k])
The first form handles reference-based aggregates. The second supplies a data array and, for operations 14–19, the required rank, percentile or quartile argument. Microsoft describes options as required but labels its table’s first behavior “0 or omitted”; these examples always provide an explicit option rather than relying on ambiguous omission syntax.
| Code | Calculation | Code | Calculation |
|---|---|---|---|
| 1 | AVERAGE | 11 | VAR.P |
| 2 | COUNT | 12 | MEDIAN |
| 3 | COUNTA | 13 | MODE.SNGL |
| 4 | MAX | 14 | LARGE |
| 5 | MIN | 15 | SMALL |
| 6 | PRODUCT | 16 | PERCENTILE.INC |
| 7 | STDEV.S | 17 | QUARTILE.INC |
| 8 | STDEV.P | 18 | PERCENTILE.EXC |
| 9 | SUM | 19 | QUARTILE.EXC |
| 10 | VAR.S |
The reference form permits up to 253 numeric/reference arguments. A function’s own input constraints still matter; changing the code does not make every dataset valid for every statistic.
Choose exclusions deliberately
| Option | Exclusions listed by Microsoft |
|---|---|
| 0 | Nested SUBTOTAL and AGGREGATE |
| 1 | Hidden rows and nested SUBTOTAL/AGGREGATE |
| 2 | Errors and nested SUBTOTAL/AGGREGATE |
| 3 | Hidden rows, errors and nested SUBTOTAL/AGGREGATE |
| 4 | None |
| 5 | Hidden rows |
| 6 | Errors |
| 7 | Hidden rows and errors |
In particular, option 6 is not the same as option 2: it ignores errors but does not request nested-total exclusion. The worked visibility cases below use manually hidden rows; arbitrary filter-state behavior is not inferred from this table alone.
Original example 1: a clean total
Enter 10, 20 and 30 in B2:B4, with all rows visible:
=AGGREGATE(9,6,B2:B4)
Expected output: 60. Code 9 sums the three values. Since there are no errors here, option 6 has nothing to remove.
Original example 2: ignore an actual source error
Put =1/0 in B5. Its result is a division-by-zero error, not the literal text “#DIV/0!”.
=AGGREGATE(9,6,B2:B5)
Expected output: 60. The three numeric cells contribute; B5 is excluded. English function names and comma separators are shown. Adapt separators for the workbook locale. All results are independently modeled, not native Excel observations.
Example 3: hidden rows require a different option
Keep B5’s error visible and manually hide row 3, containing 20. Compare:
=AGGREGATE(9,6,B2:B5)
=AGGREGATE(9,7,B2:B5)
=AGGREGATE(1,7,B2:B5)
Expected outputs are 60, 40 and 20. Option 6 includes the hidden numeric value while ignoring the error. Option 7 excludes both, leaving 10 and 30. The last formula averages those two observations; it does not divide their sum by all four source cells.
Advanced example: nested totals change option choice
Use a separate visible range D2:D4 containing 10, 20 and 30. In D5 enter =SUBTOTAL(9,D2:D4), producing 60. Compare:
=AGGREGATE(9,2,D2:D5)
=AGGREGATE(9,6,D2:D5)
Expected results are 60 and 120. Option 2 removes the nested subtotal; option 6 does not. Now put =AGGREGATE(9,6,D2:D4) in D6. Over D2:D6, options 2 and 6 give 60 and 180 respectively.
Choose exclusions from the actual data structure. Hiding errors does not justify counting a detail value again through an already calculated total.
Advanced example: supply k for order statistics
In F2:F6 enter 12, 4, =1/0, 9 and 20, with all rows visible. The usable sorted numbers are 4,9,12,20.
=AGGREGATE(14,6,F2:F6,2)
=AGGREGATE(15,6,F2:F6,2)
=AGGREGATE(12,6,F2:F6)
Expected results are 12, 9 and 10.5: second-largest, second-smallest and median. Omitting k from the code-15 formula gives a documented #VALUE! error. The required k is part of the selected operation’s syntax, not another source range.
Calculated arrays do not preserve all row exclusions
Microsoft warns that when the array argument itself contains a calculation, hidden-row and nested-total exclusion no longer work as they do for references. For example, multiplying F2:F6 by a condition creates a calculated array rather than merely passing the original reference.
A multiplication by a Boolean condition also produces zeros for rejected numeric rows. Those zeros can affect a minimum, small rank or average. An error-skipping option does not automatically remove zeros or implement an arbitrary business criterion. Keep those transformations separate and inspect the actual intermediate values.
Errors, layout and portability
The reference documents #VALUE! for a missing required second argument and for 3-D worksheet references. Hiding columns in a horizontal range does not reproduce hidden-row behavior in a vertical list.
Use SUBTOTAL for simpler filter-aware totals, and inspect LARGE or SMALL when learning rank constraints. Error exclusion can conceal incomplete data; report excluded records separately when their absence affects interpretation.
Microsoft’s Excel 2010 changes identify AGGREGATE as newly added. Earlier-file compatibility and another spreadsheet’s alternative formula are separate questions. No native text/Boolean coercion matrix, filter-interaction certification or performance benchmark is claimed here.
Related guides and official documentation
Editorial verification: Full manuscript and dedicated Microsoft reference reviewed on October 14, 2026. Original title, publication date, worked formulas and input fixtures are preserved. Expectations were independently calculated from explicit text, array or row-selection models; no native Excel execution, visibility interaction, maximum-size benchmark or file-interchange test was performed.