Many people use Excel efficiently to create reports or provide calculations for analysis. Most of the time, you may already have data when working with formulas and functions. However, there are times when you are creating a template / report before the data is available. Common functions such as SUMS and AVERAGES are very important when doing simple analysis, but missing or unavailable data can lead to formula errors, such as #DIV/0. The #DIV/0 error is produced when there is missing data, and the average function is dividing by zero or blank.
When an error is produced by formulas or functions, the IFERROR function controls what output value should be displayed in a cell.
The following example shows how you can suppress the #DIV/0 error and display a text message instead, such as “Missing Data”. A text message is a lot more user-friendly than a formula error.
SYNTAX for IFERROR function:
=IFERROR(value,value_if_error),
Where value is a number or a value resulting from a calculation; value_if_error is the output you want to display when the value or calculation results in an error, such as #DIV/0. The value_if_error can either be a blank, a number, or text (enclosed in double quotation marks).
EXAMPLE using IFERROR function:
The following example show how the IFERROR function is used to display the words “Missing Data” when the AVERAGE function displays a #DIV/0 error.
-
- Figure 1 shows the original AVERAGE function displaying the error.
- Figure 2 shows how the desired Missing Data message instead of the #DIV/0
Without IFERROR function:
Column G is calculating the average for the people (consultants), however, the missing data is causing the #DIV/0 error. When the monthly data is entered into the data cells (C6 to E9) the errors will go away. But, it esthetically more pleasing if the error were suppressed. The same goes for the Monthly Averages in Row 12.
Formula in Cell G6: =AVERAGE(C6:F6)
Formula in Cell C12: =AVERAGE(C6:C9)
Using the IFERROR function and nesting the AVERAGE function inside
Terminology: “Nesting” is the term used when you embed a function inside another.
For the YTD Average calculation in Column H, the formula nests the AVERAGE function inside the IFERROR function, but the output “Missing Data” message is displayed (since the AVERAGE function produces a #DIV/0 error).
Formula in Cell H6: =IFERROR(AVERAGE(C6:F6),“Missing Data”)
Similarly, the IFERROR function is also used in Row 16 for the Monthly Averages.
Formula in Cell C16: =IFERROR(AVERAGE(C6:C9),“Missing Data”)