## Summary

To get the maximum value in a set of data while ignoring all errors, you can use the AGGREGATE function with an option to ignore errors. In the example shown, the formula in D5 is:

``=AGGREGATE(4,6,B5:B16)``

The result is the maximum value in B5:B16 (100) ignoring the two errors that appear in the range.

## Generic formula

``=AGGREGATE(4,6,data)``

## Explanation

In this example, the goal is to return the maximum value in a set of data while ignoring any errors that might exist. This problem can be solved with the AGGREGATE function or with the MAXIFS function, as explained below.

### MAX with errors

The standard way to retrieve the maximum value in a range of data is the MAX function. However, if we try to use MAX like this:

``=MAX(B5:B16) // returns #N/A``

The MAX function returns #N/A as a result because the range B5:B16 contains errors. The problem with MAX is that it will return an error if the data contains errors.

### AGGREGATE function

The AGGREGATE function is a useful function that can run an aggregate calculation like AVERAGE, COUNT, MAX, MIN, etc., while optionally ignoring errors. A total of 19 operations are available, specified by a function number provided as the first argument. The table here contains a complete list of available operations. In this case we want to use the number 4 for function_num, which specifies the MAX operation. For the second argument, options, we provide the number 6, which indicates "ignore all errors". For array, we provide the range B5:B16. The final formula looks like this:

``````=AGGREGATE(4,6,B5:B16)
``````

To recap, the number 4 specifies MAX, and the number 6 is an option to ignore errors. With these settings, AGGREGATE returns the maximum value in the range, which is 100.

### Alternative with MAXIFS

Another way to solve this problem is with the MAXIFS function, which can calculate a max value after applying one or more conditions to filter out unwanted values. If values in the data set are known to be positive, a simple way to ignore errors is to check for values greater than zero like this:

``=MAXIFS(data,data,">0")``

This works because the "greater or equal to zero" expression effectively removes error values, and MAXIFS returns the maximum value from the remaining 10 values, 100. You can also use the MAXIFS function with more specific criteria like this:

``````=MAXIFS(data,data,"<>#N/A") // ignore NA errors
=MAXIFS(data,data,"<>#DIV/0!") // ignore DIV/0 errors
=MAXIFS(data,data,"<>#N/A",data,"<>#DIV/0!") // ignore both``````

All formulas above use the not equal to ("<>") operator. The first formula calculates a maximum after excluding #N/A errors. The second formula calculates a maximum after excluding #DIV/0! errors. The last formula uses two conditions to exclude both #N/A and #DIV/0! errors.

Author

### 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.
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://exceljet.net/formulas/max-value-ignore-all-errors", "fetch_time": 1723260510000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2024-33/segments/1722640789586.56/warc/CC-MAIN-20240810030800-20240810060800-00321.warc.gz", "warc_record_offset": 190219406, "warc_record_length": 12518, "token_count": 757, "char_count": 3075, "score": 3.59375, "int_score": 4, "crawl": "CC-MAIN-2024-33", "snapshot_type": "latest", "language": "en", "language_score": 0.7717406749725342, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00005-of-00064.parquet"}