Quick answer: XLOOKUP returns #N/A by default when it does not find a match. When the searched value appears to exist, check the actual stored value, the lookup column, the matching mode and whether the result range aligns with the lookup range.
Confirm the formula shape
A basic exact-match example is:
=XLOOKUP(E2,A2:A20,B2:B20)
Here E2 is the search key, A2:A20 is the lookup range and B2:B20 holds returned results. The lookup and result ranges should have matching row counts or matching column counts depending on search direction.
Cause 1: The key is not really identical
Values that look equal can differ because of extra spaces, invisible characters or mismatched text/number storage. Compare both cells rather than assuming matching display means matching underlying data. A first check for unexpected character counts is:
=LEN(A2)
Compare that length with the expected key. A different length can flag extra characters, but does not identify them or prove that trailing spaces are responsible. Avoid overwriting original records before confirming the issue.
Cause 2: The wrong column is being searched
XLOOKUP searches the lookup_range and returns the value in the corresponding position of the result_range. It does not automatically search every column in the table. Verify that the key appears inside the precise range passed to the formula.
Cause 3: Match mode was changed
An omitted match_mode uses exact matching by default. If a formula was copied from an advanced example, review its optional parameters and confirm approximate matching or wildcard matching is intentional.
Cause 4: Text and numbers were imported inconsistently
If one key comes from a CSV and another from direct entry, check whether one is numeric and the other is a text string. Standardize the source data type consistently across the lookup column and search keys. Converting identifiers such as 00123 to numbers can remove meaningful leading zeros, so treat identifiers as text when appropriate.
Verify the result without hiding the cause
You can supply an explicit missing-value message:
=XLOOKUP(E2,A2:A20,B2:B20,"Not found")
This makes the sheet friendlier but does not repair a mismatched value. Diagnose first; then use a fallback if appropriate for the workflow.
Sources
Editorial note: Formula examples are based on documented syntax; their execution was not independently tested in a live sheet.