AGGREGATE can run a total of 19 functions, and the function to perform is given as a number, which appears as the first argument in the function, function_num. The second argument, options, controls how AGGREGATE handles errors and values in hidden rows. See the table below for all available options. The AGGREGATE function takes four arguments: function_num, options, ref1, and ref2. For the first 13 functions supported, only the first three arguments are required: function_num specifies the operation, options sets various behaviors, and ref1 is the array of values to process. The last 6 functions require all four arguments: function_num specifies the operation, options sets various behaviors, ref1 is the array of values to process, and ref2 is the “second argument” for the function being called. For example, functions like SMALL and LARGE take a second argument, k, and ref2 represents that argument. The following six functions require the ref2 argument:

Example #1 

To return the MAX value in the range A1:A10, ignoring both errors and hidden rows, provide 4 for function number and 7 for options: To return the MIN value with the same options, change the function number to 5:

Example #2

In the example shown above, the formula in D5 is: where “values” is the named range B5:B14. The function number is 4, which specifies MAX. Options is provided as 6, to ignore errors only.

Example #3 - nth largest

The formulas in D8:D10 demonstrate how to return “nth largest” values: The function number here is 14, which runs the LARGE function. Because the LARGE function requires a k argument, it appears as the last argument in the three formulas above.

Example #4 - array operation

What makes AGGREGATE especially useful for more complex formulas is that it can handle arrays natively when the function number is 14-19. For example, to find the MAX value on Mondays, with data that includes dates and values, you could use AGGREGATE like this: Here we specify 14 for function (LARGE) and 6 for option (ignore errors). Then we build a logical expression using the TEXT function to check all dates for Mondays. The result of this operation is an array of TRUE/FALSE values, which become the denominator of the original values. FALSE evaluates as zero, and throws a #DIV/0! error. TRUE evaluates as 1 and returns the original value. The final array of values and errors acts like a filter. AGGREGATE ignores all errors and returns the largest (maximum) of the surviving values. More complete example here.

Function numbers

The table below lists the function numbers available to the AGGREGATE function, along with the name of the associated function. The third column, Ref2, indicates the “second argument” expected by the last 6 functions.

Behavior options

The AGGREGATE function has many options for ignoring errors, hidden rows, and other functions. Options are set with the options argument. Possible values are 0-7, as shown in the table below.

Notes

AGGREGATE returns a #VALUE! error if a second function argument is required, but not provided. 3D references do not work with AGGREGATE. The AGGREGATE function is designed for vertical ranges, not horizontal ranges.

Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.