Look Up a Value by Exact Key
Return an attribute from one unique identifier with XLOOKUP, using aligned bounded arrays, explicit exact matching, a controlled not-found result, and a separate uniqueness check.
| XLOOKUP Basic Exact Match, Formula Review | ||||||||||
| Compare exact matching, leftward returns, and controlled missing-key behavior. | ||||||||||
| Department mapping table | XLOOKUP review, editable keys | |||||||||
| Code | Department | Owner | Annual budget ($) | Department key | D-104 | |||||
| D-101 | Finance | Elena Ortiz | $980,000 | Owner key for left lookup | Maya Singh | |||||
| D-102 | Sales | Luis Romero | $2,400,000 | |||||||
| D-103 | Operations | Priya Shah | $1,750,000 | Example | Formula syntax | Result | ||||
| D-104 | Customer Success | Maya Singh | $1,250,000 | Default exact match | =XLOOKUP($I$11,$A$12:$A$19,$B$12:$B$19,"Not found") | Customer Success | ||||
| D-105 | Product | Noah Wilson | $3,100,000 | Explicit exact budget | =XLOOKUP($I$11,$A$12:$A$19,$D$12:$D$19,"Not found",0) | $1,250,000 | ||||
| D-106 | Engineering | Sofia Martin | $4,200,000 | Leftward return | =XLOOKUP($I$12,$C$12:$C$19,$A$12:$A$19,"Not found",0) | D-104 | ||||
| D-107 | People | Daniel Kim | $860,000 | Missing key fallback | =XLOOKUP("D-999",$A$12:$A$19,$B$12:$B$19,"Not found",0) | Not found | ||||
| D-108 | Legal | Chloe Bernard | $620,000 | |||||||
| Reliability checks | ||||||||||
| Selected department code appears exactly once | OK | |||||||||
| Looking the selected code up in the key column returns the same code | OK | |||||||||
| Missing-key example returns the controlled fallback | OK | |||||||||
Overview
Return an attribute aligned with one selected identifier in a mapping table. The example uses a department code to retrieve its department name, owner, and annual budget while controlling missing and duplicate keys separately.
When to use it
Use it to map department, account, product, customer, or employee codes to assumptions and descriptive attributes. It suits exact identifiers where one source row should exist for each key.
When not to use it
Use INDEX and MATCH when XLOOKUP is unavailable. Use XMATCH when only a key’s position is required. Use a multiple-criteria lookup when one field does not uniquely identify the record. Large recurring mappings may belong in a governed transformation workflow.
Problem
Manual searches and nested IF chains are difficult to maintain as mappings change. A lookup can still return a plausible first result when duplicate keys exist, and an unhandled missing key creates #N/A. Both conditions require deliberate controls.
Inputs
Input | Location | Sample |
|---|---|---|
Department code | | D-104 |
Source data
The synthetic mapping table in A12:D19 includes:
Code | Department | Owner | Annual budget |
|---|---|---|---|
D-101 | Finance | Elena Ortiz | $980,000 |
D-102 | Sales | Luis Romero | $2,400,000 |
D-103 | Operations | Priya Shah | $1,750,000 |
D-104 | Customer Success | Maya Singh | $1,250,000 |
D-105 | Product | Noah Wilson | $3,100,000 |
D-106 | Engineering | Sofia Martin | $4,200,000 |
D-107 | People | Daniel Kim | $860,000 |
D-108 | Legal | Chloe Bernard | $620,000 |
Codes should be unique text values. Every return array must cover the same rows as the key array.
Calculations
- Read the selected department code.
- Search the bounded code array using exact match mode.
- Return the value from an aligned attribute array.
- Supply a clear not-found result.
- Count the selected key and require exactly one occurrence.
Outputs
For D-104, the workbook returns Customer Success, Maya Singh, and an annual budget of $1,250,000. The absent code D-999 returns Not found rather than an uncontrolled error.
Formula map
=XLOOKUP($I$11,$A$12:$A$19,$D$12:$D$19,"Not found",0)
I11 is the selected key, column A is the lookup array, and column D is the budget return array. "Not found" controls absence; 0 makes exact matching explicit. Change only the return array to retrieve another attribute.
Model checks
The workbook verifies that the selected code occurs exactly once, maps back to itself in the key column, and that missing code D-999 returns the intended fallback. All three checks return OK.
Edge cases
- A missing key returns
Not found. - Duplicate keys return the first match while the uniqueness check returns
CHECK. - Leading or trailing spaces can prevent a text match.
- Numeric and text versions of the same visible ID may not match.
- Misaligned arrays return an error or the wrong attribute.
- A valid blank return must remain distinguishable from an absent key.
Common errors
- Using approximate matching for IDs: the wrong record may be returned. Require exact mode.
- Ignoring duplicates: a plausible first result hides ambiguous master data. Keep COUNTIF validation.
- Selecting different array sizes: rows stop corresponding. Align the boundaries.
- Omitting a fallback: missing mappings become uncontrolled errors. Define the intended response.
Example
D-104 appears once in A12:A19, at the row containing Customer Success, Maya Singh, and $1,250,000. XLOOKUP returns each aligned field when its return array changes. Searching D-999 finds no row and returns the documented fallback.
Example workbook
Edit the cream key in Combined Example!I11 or the mapping rows in A12:D19. Three mapped outputs and controls update automatically. Formula Review compares default and explicit exact matches, a leftward return, and missing-key behavior.
Key takeaway
Use one unique exact key, aligned bounded arrays, and an intentional not-found result; a separate occurrence check protects the lookup from ambiguous duplicate source rows.