XLOOKUP Returning 0 Instead of Blank: How to Fix It
In this article
When XLOOKUP finds a cell that is actually empty, Excel returns 0 rather than a blank, because an empty cell in the lookup array is treated as the number zero. The fix is to wrap XLOOKUP in an IF or IFERROR test so that an empty (or genuinely 0) result is replaced with an empty string. The most common working pattern is =IF(XLOOKUP(A2,D:D,E:E)="","",XLOOKUP(A2,D:D,E:E)), which displays a blank whenever the matched cell is empty. Below is the full step-by-step guide, plus variations for the cases where the zero is real data or the lookup fails entirely.
What You'll Need
- Excel for Microsoft 365 or Excel 2021 and later (XLOOKUP is not available in Excel 2019 or earlier, and not on the perpetual versions before 2021)
- A worksheet with a lookup table containing some empty cells in the return column
Step-by-Step
- Confirm the zero comes from an empty cell. Click the source cell XLOOKUP is returning. If the formula bar is empty, the 0 is Excel's default behaviour for blank results. If the cell actually contains a 0, XLOOKUP is working correctly and you may not need to change anything.
- Write the basic XLOOKUP first. For example, if your lookup value is in A2 and your table has IDs in column D and values in column E, enter =XLOOKUP(A2, D:D, E:E) in the cell where you want the result.
- Wrap it in an IF test for an empty string. Change the formula to =IF(XLOOKUP(A2,D:D,E:E)="","",XLOOKUP(A2,D:D,E:E)). When the matched cell is empty, XLOOKUP returns 0, the test 0="" is TRUE inside IF (Excel treats an empty string result as equal to "" here), and the formula outputs a blank instead.
- Press Enter and fill down. Drag the fill handle (or double-click it) to copy the formula down the column. Empty source cells now show as blank instead of 0.
- Add a not-found message if needed. If some lookup values may not exist in the table at all, use the if_not_found argument: =IF(XLOOKUP(A2,D:D,E:E,"Not found")="","",XLOOKUP(A2,D:D,E:E,"Not found")). This keeps genuine missing matches visible while still blanking empty cells.
- Optional: use LET to avoid running the lookup twice. On large sheets, =LET(r,XLOOKUP(A2,D:D,E:E),IF(r="","",r)) does the lookup once, stores it as r, and returns a blank when r is empty. This is cleaner and faster on big tables.
- Optional: hide zeros across the whole sheet instead. If you would rather leave your formulas alone, go to File > Options > Advanced and untick Show a zero in cells that have zero value. This hides all zeros on that sheet, including real ones, so only use it if genuine zeros do not matter. (Menu labels can differ slightly between Excel versions and platforms.)
Common Mistakes
- Using IFERROR to catch blanks. IFERROR only handles error values like #N/A; a 0 is not an error, so =IFERROR(XLOOKUP(...),"") will still show 0. Save IFERROR for genuinely missing lookups.
- Testing for 0 instead of "". A formula like =IF(XLOOKUP(...)=0,"",XLOOKUP(...)) also blanks real zeros, which may be valid data such as a zero balance or zero count.
- Formatting the returned 0 as text and then wondering why comparisons fail. A blank returned by "" is text, so downstream formulas that do arithmetic on it can produce #VALUE!. If other formulas use the result in calculations, consider leaving the 0 or testing with ISNUMBER first.
- Forgetting that trailing spaces in the lookup column cause #N/A, which looks like a blank problem but is not. Use TRIM on the data if lookups fail unexpectedly.
- Applying the hide-zeros option to fix one column and then losing legitimate zeros elsewhere on the sheet.
Tips
- The LET version is worth learning: it reads clearly, runs the lookup only once, and works for INDEX/MATCH and VLOOKUP fixes too.
- If you want an empty string to behave like a true blank in calculations, test with ISBLANK on the source range instead: =IF(ISBLANK(XLOOKUP(A2,D:D,E:D)),"",XLOOKUP(A2,D:D,E:E)) is overkill for most cases; the simple "" test is usually enough.
- Number formatting can also suppress zeros without touching formulas: select the cells, press Ctrl+1, choose Custom, and use a format like 0;-0;;@, which shows nothing for zero values while keeping real numbers intact underneath.
- This same zero-for-blank behaviour applies to VLOOKUP and INDEX/MATCH, so the IF wrapper pattern transfers directly if you ever convert formulas.
Troubleshooting
- Still seeing 0 after adding the IF wrapper: check that the source cell is truly empty and not containing a space, a non-breaking character, or a formula that returns "" already. Use =LEN(cell) on the source; anything other than 0 means it is not empty, and the IF test needs adjusting (for example, testing TRIM of the result).
- Getting #N/A instead of a value: the lookup value does not exist in the lookup column. Check for extra spaces, number-vs-text mismatches (a number stored as text will not match), and trailing characters. Wrap the lookup value or column in TRIM, or add the if_not_found argument to handle it gracefully.
- Getting #NAME?: your Excel version does not support XLOOKUP. Use Excel 2021 or Microsoft 365, or switch to INDEX/MATCH: =IF(INDEX(E:E,MATCH(A2,D:D,0))="","",INDEX(E:E,MATCH(A2,D:D,0))).
- Downstream formulas now show #VALUE! or break: the "" result is text. Change dependent formulas to test with ISNUMBER first, or revert to showing 0 where arithmetic matters.
- Everything looks right but results are stale: check that calculation is set to Automatic under Formulas > Calculation Options, then press F9 to force a recalculation.
Frequently Asked Questions
Why does XLOOKUP return 0 for empty cells?
Excel treats an empty cell as the number zero when it is returned by a formula. XLOOKUP is faithfully returning the empty cell's value, which Excel represents as 0. This is expected behaviour, not a bug.
Does the same fix work in Google Sheets?
Yes, the same IF wrapper pattern works in Google Sheets, which has XLOOKUP and the same zero-for-blank behaviour. The LET function is also supported there.
Will the blank from "" affect other formulas?
It can. The result is an empty text string, not a true blank, so arithmetic on it produces #VALUE!. Functions like SUM and AVERAGE ignore it, but direct addition (like +) does not. Test with ISNUMBER if dependent formulas do calculations.
Is there a setting to make XLOOKUP return blanks automatically?
No. There is no XLOOKUP argument for blank handling. You must wrap the formula in IF (or LET) or hide zeros via worksheet options or number formatting.
What if 0 is a real value in my data?
Use the "" comparison, not a 0 comparison. An empty cell returned by XLOOKUP compares as equal to "" in this context, while a genuine 0 stored in the source cell will still pass through and display correctly with the standard IF wrapper.