The IFNA function in Google Sheets helps you handle #N/A errors effectively. It evaluates a value or expression, and if it results in an #N/A error, it replaces it with a specified custom value instead.
The IFNA function is particularly useful when working with lookup functions like VLOOKUP, HLOOKUP, MATCH, or XMATCH. Often, when a lookup function cannot find a match, it returns an #N/A error. Instead of displaying the error, you can use IFNA to return a clearer message or a blank cell, helping users understand that the lookup value was simply not found.
However, keep in mind that not all #N/A errors mean “not available.” Some functions return #N/A if the number of required or specified arguments is incorrect. So, before using IFNA to replace an error, make sure the formula itself is correctly written and the #N/A truly means the data is missing.
IFNA Function Syntax and Arguments
Syntax:
IFNA(value, value_if_na)
Arguments:
- value – The value or expression to evaluate for an #N/A error.
- value_if_na – The value to return if the first argument results in an #N/A error.
Recommended Functions to Use with IFNA
You can use the IFNA function with many functions in Google Sheets, especially lookup-related ones. Here’s a quick reference:
Function | When It Returns #N/A |
VLOOKUP | When the lookup value is not found in the first column of the range. |
HLOOKUP | When the lookup value is not found in the first row of the range. |
MATCH | If the lookup value is not found within the specified range. |
XMATCH | If the lookup value is not found in the array or range. |
XLOOKUP | If the lookup value is not found and no if_not_found argument is provided. |
LOOKUP | If the search value is smaller than the smallest value in the array/range (in certain cases). |
FILTER | When no rows meet the filter criteria. |
SWITCH | When the expression does not match any of the provided cases. |
IFS | When none of the conditions evaluate as TRUE. |
Using IFNA with these functions ensures that your spreadsheet looks clean and users understand that a result was simply not available, rather than seeing confusing error messages.
IFNA Function Examples
Imagine you have student names in column A and their marks in column B.
Here’s a basic VLOOKUP formula that might return an #N/A error if the student name isn’t found:
=VLOOKUP("Tom", A1:B10, 2, FALSE)
If “Tom” isn’t listed in column A, this formula returns #N/A.
Instead, use IFNA to handle the error:
Example 1: Return a blank if not found:
=IFNA(VLOOKUP("Tom", A1:B10, 2, FALSE))
Example 2: Return a custom message:
=IFNA(VLOOKUP("Tom", A1:B10, 2, FALSE), "Name not found!")
These formulas ensure your sheet stays clean and user-friendly, replacing the #N/A error with either an empty cell or a clear message like “Name not found!”.