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.
7. Function not working
The IFNA function returns
- #NAME? error if you misspell the function name.
- propagates errors, meaning that if the input contains an error (e.g., #VALUE!, #REF!), the function will return the same error.
7.1 Troubleshooting the error value
When you encounter an error value in a cell a warning symbol appears, displayed in the image above. Press with mouse on it to see a pop-up menu that lets you get more information about the error.
- The first line describes the error if you press with left mouse button on it.
- The second line opens a pane that explains the error in greater detail.
- The third line takes you to the "Evaluate Formula" tool, a dialog box appears allowing you to examine the formula in greater detail.
- This line lets you ignore the error value meaning the warning icon disappears, however, the error is still in the cell.
- The fifth line lets you edit the formula in the Formula bar.
- The sixth line opens the Excel settings so you can adjust the Error Checking Options.
Here are a few of the most common Excel errors you may encounter.
#NULL error - This error occurs most often if you by mistake use a space character in a formula where it shouldn't be. Excel interprets a space character as an intersection operator. If the ranges don't intersect an #NULL error is returned. The #NULL! error occurs when a formula attempts to calculate the intersection of two ranges that do not actually intersect. This can happen when the wrong range operator is used in the formula, or when the intersection operator (represented by a space character) is used between two ranges that do not overlap. To fix this error double check that the ranges referenced in the formula that use the intersection operator actually have cells in common.
#SPILL error - The #SPILL! error occurs only in version Excel 365 and is caused by a dynamic array being to large, meaning there are cells below and/or to the right that are not empty. This prevents the dynamic array formula expanding into new empty cells.
#DIV/0 error - This error happens if you try to divide a number by 0 (zero) or a value that equates to zero which is not possible mathematically.
#VALUE error - The #VALUE error occurs when a formula has a value that is of the wrong data type. Such as text where a number is expected or when dates are evaluated as text.
#REF error - The #REF error happens when a cell reference is invalid. This can happen if a cell is deleted that is referenced by a formula.
#NAME error - The #NAME error happens if you misspelled a function or a named range.
#NUM error - The #NUM error shows up when you try to use invalid numeric values in formulas, like square root of a negative number.
#N/A error - The #N/A error happens when a value is not available for a formula or found in a given cell range, for example in the VLOOKUP or MATCH functions.
#GETTING_DATA error - The #GETTING_DATA error shows while external sources are loading, this can indicate a delay in fetching the data or that the external source is unavailable right now.
7.2 The formula returns an unexpected value
To understand why a formula returns an unexpected value we need to examine the calculations steps in detail. Luckily, Excel has a tool that is really handy in these situations. Here is how to troubleshoot a formula:
- Select the cell containing the formula you want to examine in detail.
- Go to tab “Formulas” on the ribbon.
- Press with left mouse button on "Evaluate Formula" button. A dialog box appears.
The formula appears in a white field inside the dialog box. Underlined expressions are calculations being processed in the next step. The italicized expression is the most recent result. The buttons at the bottom of the dialog box allows you to evaluate the formula in smaller calculations which you control. - Press with left mouse button on the "Evaluate" button located at the bottom of the dialog box to process the underlined expression.
- Repeat pressing the "Evaluate" button until you have seen all calculations step by step. This allows you to examine the formula in greater detail and hopefully find the culprit.
- Press "Close" button to dismiss the dialog box.
There is also another way to debug formulas using the function key F9. F9 is especially useful if you have a feeling that a specific part of the formula is the issue, this makes it faster than the "Evaluate Formula" tool since you don't need to go through all calculations to find the issue..
- Enter Edit mode: Double-press with left mouse button on the cell or press F2 to enter Edit mode for the formula.
- Select part of the formula: Highlight the specific part of the formula you want to evaluate. You can select and evaluate any part of the formula that could work as a standalone formula.
- Press F9: This will calculate and display the result of just that selected portion.
- Evaluate step-by-step: You can select and evaluate different parts of the formula to see intermediate results.
- Check for errors: This allows you to pinpoint which part of a complex formula may be causing an error.
The image above shows cell reference B6 converted to hard-coded value using the F9 key. The IFNA function requires non-error values except #N/A errors which is not the case in this example. We have found what is wrong with the formula.
Tips!
- View actual values: Selecting a cell reference and pressing F9 will show the actual values in those cells.
- Exit safely: Press Esc to exit Edit mode without changing the formula. Don't press Enter, as that would replace the formula part with the calculated value.
- Full recalculation: Pressing F9 outside of Edit mode will recalculate all formulas in the workbook.
Remember to be careful not to accidentally overwrite parts of your formula when using F9. Always exit with Esc rather than Enter to preserve the original formula. However, if you make a mistake overwriting the formula it is not the end of the world. You can “undo” the action by pressing keyboard shortcut keys CTRL + z or pressing the “Undo” button
7.3 Other errors
Floating-point arithmetic may give inaccurate results in Excel - Article
Floating-point errors are usually very small, often beyond the 15th decimal place, and in most cases don't affect calculations significantly.
'IFNA' function examples
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 […]
Excel 2010 has a PowerPivot feature and DAX formulas that let you work with multiple tables of data. You can […]
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