How to use the IFNA function
What is the IFNA function?
The IFNA function handles #N/A errors only, it returns a value you specify if the formula returns a #N/A error.
Table of Contents
1. Introduction
What is the #N/A error value?
The #N/A means Not Available and it occurs when a value is not available for a formula or found in a given cell range, for example in the VLOOKUP or MATCH functions.
What is the difference between the IFNA, NA, ISNA functions?
The IFNA, NA, and ISNA functions in Excel serve different purposes related to handling #N/A errors.
- The IFNA function replaces #N/A errors with a specified value.
Syntax: IFNA(value, value_if_na)
Wraps around a formula that might produce #N/A providing an alternative result. - NA function deliberately returns the #N/A error value.
Syntax: NA()
Used when you want to indicate that a value is not available. - ISNA function tests whether a value is #N/A.
Syntax: ISNA(value)
Returns TRUE if the value is #N/A, FALSE otherwise.
- Example: IF(ISNA(VLOOKUP(...)), "Not found", "Found")
IFNA is often the most convenient for error handling in formulas, while ISNA is useful in more logical operations. NA is less commonly used but can be helpful in specific scenarios where you want to intentionally mark a cell as not available.
This setup illustrates how Excel handles #N/A errors in charts, treating them as gaps rather than zero values or connected points. It's a useful way to visually represent missing or unavailable data in a chart without skewing the representation of other data points.
There's a column chart titled "#N/A error" in the image above, it displays values for categories A, B, C, D, and E. Categories A, B, C, and E have visible columns,however, category D have no column due to #N/A value.
Below the chart is a small data table with two columns: "Category" and "Value". Values are: A:2, B:5, C:3, D:#N/A, E:2
The #N/A in cell B22 is created using the NA() function.
A "Hidden and Empty Cell Settings" dialog box is open, it shows options for how to display empty cells in charts. The selected option is "Gaps", which explains why the #N/A value appears as a gap in the chart. "Show #N/A as an empty cell" is checked treating #N/A values as empty cells in the chart.
The formula bar shows =NA() in cell B19, demonstrating how to generate an #N/A error deliberately
The NA function lets you return the #N/A error in any formula you like. You can for instance use the IF function and a logical expression to determine when the error should occur.
Related #N/A functions
Excel Function | Description |
---|---|
NA() | Returns the #N/A error value |
IFNA(value, value_if_na) | Returns value_if_na if value is #N/A, otherwise returns value |
ISNA(value) | Returns TRUE if value is #N/A, FALSE otherwise |
ISERR(value) | Returns TRUE if value is any error except #N/A, otherwise FALSE |
ISERROR(value) | Returns TRUE if value is any error value, FALSE otherwise |
IFERROR(value, value_if_error) | Returns value_if_error if value is any error, otherwise returns value |
2. Syntax
IFNA(value, value_if_na)
value | Required. The value you want to check. |
value_if_na | Required. The value to return if the value argument returns #N/A. |
3. Example 1
This example demonstrates how to use the IFNA function. The image above shows values in cell range C3:C28, enter a lookup value in cell F2 and the formula in cell F3 returns the position of that particular value in cells C3:C28.
The MATCH function returns a #N/A error if the value is not found, the IFNA function catches that error and returns another value that you can specify. This example uses "Not found!" if the value in cell F2 is not found in cells C3:C28.
Formula in cell F3:
Here is a detailed explanation of how the formula works:
- MATCH(F2,C3:C28,0)
This function searches for the value in cell F2 (which is "FD") within the range C3:C28. The 0 at the end specifies an exact match. - IFNA(..., "Not found!")
This function wraps the MATCH function. If MATCH finds a result, IFNA returns that result. If MATCH returns an error (which happens when no match is found), IFNA returns the text "Not found!".
4. Example 2
This second example also shows how to use the IFNA function. The image above shows values in cell range C3:C12, enter a lookup value in cell F2 and the formula in cell F3 returns the position of that particular value in cells C3:C12.
This formula is designed to look up a value in column C, return the corresponding value from column B if found, or display "Not found!" if the value doesn't exist in the list. It's a way to create a more user-friendly output for lookup operations that might not always find a match.
Formula in cell F3:
The lookup value "QS" (in cell F2) is not found in the range C3:C12. So XLOOKUP would normally return an #N/A error. IFNA catches this error and returns "Not found!" instead.
Here is a detailed explanation of how the formula works:
- XLOOKUP(F2,C3:C12,B3:B12,0,1):
- F2 is the lookup value ("QS" in this case)
- C3:C12 is the lookup array (where it searches for the value)
- B3:B12 is the return array (what it returns if it finds a match)
- 0 is the match mode (0 means exact match)
- 1 is the search mode (1 means search first to last)
- IFNA(..., "Not found!"):
- This function wraps the XLOOKUP. If XLOOKUP finds a result, IFNA returns that result. If XLOOKUP returns an #N/A error (which happens when no match is found), IFNA returns the text "Not found!".
5. Example 3
This is the third example that shows how to combine the IFNA function and the VLOOKUP function. The image above shows values in cell range C3:C12, enter a lookup value in cell F2 and the formula in cell F3 finds the value in cells B3:B12 and returns the amount from cells C3:C12 on the same row.
The formula works as follows. It tries to find the value in F2 ("FD") in the first column of the range B3:C10. If found, it would return the corresponding value from the second column. If not found, VLOOKUP would normally return #N/A. However, the IFNA function catches this #N/A error and replaces it with "Not found!"
Formula in cell F3:
In this case, "FD" is not in the lookup table, so the result is "Not found!" as we see in cell F3. This formula provides a more user-friendly output when a value isn't found, instead of showing an error.
Here is a detailed explanation of how the formula works:
- VLOOKUP(F2,B3:C10,2,FALSE):
- F2 is the lookup value (in this case, "FD")
- B3:C10 is the table array to search in
- The third argument is 2 which indicates we want to return a value from the second column of the array
- FALSE specifies an exact match in contrast to TRUE that makes the function return an approximate match.
- IFNA( ... , "Not found!"):
- This function wraps the VLOOKUP
If VLOOKUP returns an #N/A error (when the value isn't found), it replaces it with "Not found!"
- This function wraps the VLOOKUP
6. When to use the function?
Use the IFNA function instead of the IFERROR function to check for #N/A errors specifically. For example, VLOOKUP returns #N/A when it can't find the lookup value.
The IFERROR function checks for all error values which in most cases is not recommended. This makes it harder to spot a more serious error since all error values are handled.
'IFNA' function examples
Table of Contents How to use the CHOOSECOLS function How to use the CHOOSEROWS function How to use the DROP […]
Table of contents Filter unique distinct row records Filter unique distinct row records but not blanks Filter unique distinct row […]
This article demonstrates ways to extract names and corresponding populated date ranges from a schedule using Excel 365 and earlier […]
Functions in 'Logical' category
The IFNA function function is one of 16 functions in the 'Logical' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form