How to Use AGGREGATE Function in Excel + Tips

Learn how to use AGGREGATE function in Excel step-by-step to calculate SUM, AVERAGE, MAX, LARGE while ignoring errors and hidden rows.

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

Hello everyone! Today i will show you how to use AGGREGATE function in Microsoft Excel step by step.


1. What is AGGREGATE Function in Excel?

The AGGREGATE function is one of the most powerful math & statistical formulas in Excel. It allows you to perform 19 different calculations (such as SUM, AVERAGE, COUNT, LARGE, SMALL) while automatically ignoring error values (#DIV/0!, #N/A, #VALUE!) and hidden rows from filters.

Unlike standard SUM or AVERAGE formulas that crash when encountering error cells, AGGREGATE skips errors smoothly!

📚 Related Tutorial: Need a simple formula for filtered data? Check out How to Use SUBTOTAL Function in Excel!


2. 🛠️ Formula Syntax & Parameters

AGGREGATE has two forms depending on which function you choose:

Form 1: Reference Form (for functions 1 to 13)

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

Form 2: Array Form (for functions 14 to 19)

=AGGREGATE(function_num, options, array, k)
  • function_num: Required. A number from 1 to 19 specifying which calculation to perform (e.g., 9 = SUM, 1 = AVERAGE, 14 = LARGE).
  • options: Required. A number from 0 to 7 specifying what values Excel should ignore (e.g., 6 = ignore errors, 3 = ignore hidden rows & errors).
  • ref1 / array: Required. The range of cells to perform calculation on (e.g., B2:B6).
  • k: Required only for array functions (14 to 19). Represents the k-th position (e.g., k = 2 for 2nd largest value).

3. Reference Tables

Function Number Reference (function_num)

function_numFunction NameDescriptionSyntax Form
1AVERAGECalculates the average of valuesReference
2COUNTCounts cells with numbersReference
3COUNTACounts non-empty cellsReference
4MAXFinds the maximum (largest) valueReference
5MINFinds the minimum (smallest) valueReference
6PRODUCTMultiplies all numbers togetherReference
7STDEV.SCalculates sample standard deviationReference
8STDEV.PCalculates population standard deviationReference
9SUMCalculates the total sum of valuesReference
10VAR.SCalculates sample varianceReference
11VAR.PCalculates population varianceReference
12MEDIANCalculates the median valueReference
13MODE.SNGLCalculates the most frequent valueReference
14LARGEFinds the k-th largest valueArray (requires k)
15SMALLFinds the k-th smallest valueArray (requires k)
16PERCENTILE.INCCalculates k-th percentile (inclusive)Array (requires k)
17QUARTILE.INCCalculates k-th quartile (inclusive)Array (requires k)
18PERCENTILE.EXCCalculates k-th percentile (exclusive)Array (requires k)
19QUARTILE.EXCCalculates k-th quartile (exclusive)Array (requires k)

Options Reference (options)

optionsDescriptionTypical Use Case
0Ignore nested SUBTOTAL and AGGREGATE functionsSafe sub-totaling without double counting
1Ignore nested SUBTOTAL/AGGREGATE functions and hidden rowsFiltered data sub-totaling
2Ignore error values only (#DIV/0!, #N/A, #VALUE!, etc.)Ranges containing formula error cells
3Ignore hidden rows, error values, and nested SUBTOTAL/AGGREGATEComplete cleanup for filtered tables
4Ignore nothingCalculate everything standard
5Ignore hidden rows onlyFiltered data without error handling
6Ignore error values onlySimple error cleanup
7Ignore nested SUBTOTAL/AGGREGATE functions and error valuesMulti-level subtotaling with errors

Advertisement

4. 📋 Practical Examples (Follow Along)

To test these examples, create this sample table in range A1:B6:

RowColumn A (Item)Column B (Sales)
1ItemSales
2Item A$500
3Item B#DIV/0! (Error)
4Item C$800
5Item D (Hidden)$300
6Item E$400

Example 1: Sum Numbers Ignoring #DIV/0! Errors

Standard =SUM(B2:B6) will break and return #DIV/0!. Using AGGREGATE with function_num = 9 (SUM) and options = 6 (Ignore Errors):

=AGGREGATE(9, 6, B2:B6)

👉 Result: $2,000 ($500 + $800 + $300 + $400). Excel skips the error cell automatically!


Example 2: Sum Visible Rows Ignoring Both Errors and Hidden Rows

Suppose Row 5 (Item D) is hidden by a filter or manually hidden. Use function_num = 9 (SUM) and options = 3 (Ignore Hidden Rows & Errors):

=AGGREGATE(9, 3, B2:B6)

👉 Result: $1,700 ($500 + $800 + $400). It ignores both the #DIV/0! error and hidden Row 5!


Example 3: Find 2nd Largest Value (LARGE) Ignoring Errors

Standard =LARGE(B2:B6, 2) fails due to the #DIV/0! error. Use function_num = 14 (LARGE), options = 6 (Ignore Errors), and k = 2:

=AGGREGATE(14, 6, B2:B6, 2)

👉 Result: $500 (2nd largest number after $800).


💡 Quick Tips for Using AGGREGATE Function

  1. Option 6 for Quick Error Cleanup: Use options = 6 whenever you need to calculate totals or averages on data containing #N/A, #DIV/0!, #VALUE!, or #REF! errors without breaking your formula.
  2. Option 3 for Filtered Tables with Errors: Option 3 is the ultimate cheat code for filtered data tables because it ignores hidden rows, errors, and nested subtotals all at once.
  3. No Need for Complex IFERROR Wrappers: Instead of writing complex array formulas like =SUM(IFERROR(B2:B6, 0)), simply write =AGGREGATE(9, 6, B2:B6)!
  4. Remember k Argument for Functions 14 to 19: Functions 14 (LARGE), 15 (SMALL), and 16-19 require a 4th argument k (e.g., k = 1 for 1st largest). For functions 1 to 13, leave k empty.

📚 Related Resources & Tutorials

Found this tutorial helpful? Share it with colleagues:
📚

Related Tutorials

Opens in new tab ↗
Advertisement