Today, we’re going to be talking about the IFERROR function and how it can help you streamline your spreadsheet work.
If you’ve ever used a spreadsheet before, you know that errors can pop up from time to time. Maybe you’ve accidentally entered a formula incorrectly, or maybe you’re trying to reference a cell that is empty. Whatever the case may be, errors can be frustrating and time-consuming to fix. That’s where the IFERROR function comes in. This handy function allows you to specify what should happen when an error occurs in a formula. With IFERROR, you can choose to display a custom message, return a different value, or even ignore the error entirely. In short, IFERROR can save you a lot of time and headaches by helping you manage errors in your spreadsheet more efficiently.
Table of Contents
Definition of IFERROR Function
The IFERROR function in Google Sheets is a built-in function that allows you to specify what should happen when an error occurs in a formula. It has the syntax IFERROR(value, value_if_error), where value is the value that you want to test for an error, and value_if_error is the value that should be returned if an error occurs. For example, if you wanted to display a custom message if an error occurred in a formula, you could use the formula =IFERROR(A1/B1, “Error occurred”). This would display the result of the formula A1/B1 if it is successful, and display the message “Error occurred” if an error occurs. The IFERROR function can be used in many different situations to help you manage errors in your spreadsheet more efficiently.
Syntax of IFERROR Function
The syntax of the IFERROR function in Google Sheets is as follows:
=IFERROR(value, value_if_error)
- value: This is the value that you want to test for an error. This can be a cell reference, a formula, or any other value that you want to check for an error.
- value_if_error: This is the value that should be returned if an error occurs. This can be a cell reference, a formula, a text string, or any other value that you want to display if an error occurs.
Here’s an example of how you might use the IFERROR function in a formula:
=IFERROR(A1/B1, "Error occurred")
In this example, the formula A1/B1 is being tested for an error. If an error occurs, the message “Error occurred” will be displayed. If no error occurs, the result of the formula A1/B1 will be displayed.
You can also use a formula as the value_if_error argument, like this:
=IFERROR(A1/B1, C1*D1)
In this example, if an error occurs in the formula A1/B1, the result of the formula C1*D1 will be displayed instead.
Examples of IFERROR Function
Here are three examples of how you might use the IFERROR function in Google Sheets:
- Displaying a custom message if an error occurs:
Suppose you have a spreadsheet with a formula in cell A1 that divides the value in cell B1 by the value in cell C1. If either B1 or C1 is empty, or if C1 contains a value of 0, the formula will return an error. To display a custom message instead of the error, you can use the IFERROR function like this:=IFERROR(B1/C1, "Error: check input values")
If an error occurs, the message “Error: check input values” will be displayed in cell A1. If no error occurs, the result of the formula B1/C1 will be displayed.
- Returning a different value if an error occurs:
Suppose you have a spreadsheet with a formula in cell A1 that calculates the average of the values in cells B1 through B10. If any of the cells in the range B1:B10 are empty, the formula will return an error. To return a value of 0 instead of the error, you can use the IFERROR function like this:=IFERROR(AVERAGE(B1:B10), 0)
If an error occurs, the value 0 will be displayed in cell A1. If no error occurs, the average of the values in cells B1 through B10 will be displayed.
- Ignoring errors and displaying the result of a formula:
Suppose you have a spreadsheet with a formula in cell A1 that multiplies the value in cell B1 by the value in cell C1. If either B1 or C1 is empty, the formula will return an error. To ignore the error and display the result of the formula anyway, you can use the IFERROR function like this:=IFERROR(B1*C1, B1*C1)
In this example, the value and value_if_error arguments are both the formula B1*C1. If an error occurs, the formula will be evaluated again as the value_if_error argument and the result will be displayed. If no error occurs, the result of the formula will be displayed as usual.
Use Case of IFERROR Function
Here are a few real-life examples of how you might use the IFERROR function in Google Sheets:
- Cleaning up data imports:
Suppose you have a spreadsheet that you use to track sales data from multiple sources. You import the data from each source into a separate sheet, and then use formulas to combine the data into a single sheet for analysis. If any of the data is missing or incorrect, the formulas will return errors. To display a custom message instead of the errors, you can use the IFERROR function like this:=IFERROR(A1/B1, "Error: check input values")
This formula will display the result of the formula A1/B1 if it is successful, and display the message “Error: check input values” if an error occurs. You can use this formula in every cell that has a formula that might return an error, to help you quickly identify and fix any problems with your data.
- Calculating totals with missing data:
Suppose you have a spreadsheet that tracks the inventory levels of different products in your store. You have a formula in cell A1 that calculates the total value of all the products in your store, using the formula =SUM(B1:B10). If any of the cells in the range B1:B10 are empty, the formula will return an error. To return a value of 0 instead of the error, you can use the IFERROR function like this:=IFERROR(SUM(B1:B10), 0)
This formula will calculate the total value of all the products in your store if the data is complete, and return a value of 0 if any of the cells in the range B1:B10 are empty. This can be useful if you want to calculate a total even if some of the data is missing.
- Validating user input:
Suppose you have a spreadsheet that you use to track expenses for your business. You have a formula in cell A1 that calculates the total expenses for the month, using the formula =SUM(B1:B10). You want to make sure that the user enters only positive numbers in the range B1:B10, so you use the IFERROR function to validate the input like this:=IFERROR(SUM(B1:B10), "Error: negative value entered")
This formula will calculate the total expenses for the month if all the values in the range B1:B10 are positive, and display the message “Error: negative value entered” if any of the values are negative. This can be useful if you want to make sure that the user enters only valid data in your spreadsheet.
Limitations of IFERROR Function
There are a few limitations of the IFERROR function in Google Sheets that you should be aware of:
- The IFERROR function can only handle errors that are caused by formulas. It cannot handle other types of errors, such as data validation errors or circular reference errors.
- The IFERROR function can only handle errors that are returned by formulas. It cannot handle errors that are caused by invalid cell references or invalid data types.
- The IFERROR function can only handle errors that are returned by formulas. It cannot handle errors that are caused by external data sources or by other functions.
- The IFERROR function can only handle errors that are returned by formulas. It cannot handle errors that are caused by user input or by other factors outside of the spreadsheet.
- The IFERROR function does not prevent errors from occurring. It only allows you to specify what should happen when an error occurs. You still need to make sure that your formulas are correct and that your data is valid in order to avoid errors.
Commonly Used Functions Along With IFERROR
Here is a list of commonly used functions that are often used along with the IFERROR function in Google Sheets:
- AVERAGE: Calculates the average of a range of cells.
To use the AVERAGE function with the IFERROR function, you can use a formula like this:=IFERROR(AVERAGE(B1:B10), 0)
This formula will calculate the average of the values in cells B1 through B10 if the data is complete, and return a value of 0 if any of the cells in the range B1:B10 are empty.
- SUM: Calculates the sum of a range of cells.
To use the SUM function with the IFERROR function, you can use a formula like this:=IFERROR(SUM(B1:B10), 0)
This formula will calculate the sum of the values in cells B1 through B10 if the data is complete, and return a value of 0 if any of the cells in the range B1:B10 are empty.
- COUNT: Counts the number of cells in a range that contain a number.
To use the COUNT function with the IFERROR function, you can use a formula like this:=IFERROR(COUNT(B1:B10), 0)
This formula will count the number of cells in the range B1:B10 that contain a number if the data is complete, and return a value of 0 if any of the cells in the range B1:B10 are empty.
- VLOOKUP: Looks up a value in a table and returns a corresponding value from a different column in the same row.
To use the VLOOKUP function with the IFERROR function, you can use a formula like this:=IFERROR(VLOOKUP(A1, B1:C10, 2, FALSE), "Not found")
This formula will look up the value in cell A1 in the table in the range B1:C10, and return the corresponding value from the second column of the table if the value is found. If the value is not found, the message “Not found” will be displayed.
Summary
The IFERROR function in Google Sheets is a powerful tool that allows you to specify what should happen when an error occurs in a formula. By using the IFERROR function, you can save time and avoid headaches by managing errors more efficiently in your spreadsheet.
Some key points to remember about the IFERROR function are:
- The syntax of the IFERROR function is IFERROR(value, value_if_error), where value is the value that you want to test for an error, and value_if_error is the value that should be returned if an error occurs.
- The IFERROR function can be used to display a custom message if an error occurs, return a different value if an error occurs, or ignore the error entirely.
- The IFERROR function can only handle errors that are caused by formulas. It cannot handle other types of errors, such as data validation errors or circular reference errors.
- The IFERROR function does not prevent errors from occurring. It only allows you to specify what should happen when an error occurs. You still need to make sure that your formulas are correct and that your data is valid in order to avoid errors.
If you want to streamline your spreadsheet work and make your life easier, we encourage you to try using the IFERROR function in your own Google Sheets. With a little bit of practice, you’ll be a pro at managing errors in no time!
Video: IFERROR Function
In this video, you will see how to use IFERROR function. We suggest you to watch the video to understand the usage of IFERROR formula.