Why does XLOOKUP return one portrait file when my production ledger has two matching keys?
The ledger is an external production aid. Its invented key fields are not promised AISwapLab API fields, and the sheet does not change the website’s selected replacement photos. This documentation-based procedure is unexecuted. The native decision is a scalar lookup’s treatment of multiple matches, not preservation of leading zeros, ordinary row sorting or a general source-to-person worksheet.
What to do next
- 01
Define one lookup key’s intended cardinality
Preserve the workbook and describe whether a key should identify one approved asset version, a family of versions or several role assignments. Inspect the source rows with that exact key before reviewing the lookup result. If revisions share a key, decide which additional version or approval component is required to identify one record. Do not delete duplicates automatically: two records can be legitimate history even though they are unsafe inputs for a formula expected to return one current assignment.
- 02
Inspect match and search policy explicitly
Review XLOOKUP’s match_mode and search_mode rather than assuming exact means unique. Microsoft documents exact matching as the default and first-to-last search as the default, with reverse search available. For the diagnostic fixture, inspect all source records for the key and compare the chosen result with the approved cardinality rule. A helper count such as =COUNTIF(A2:A4,E2) can flag multiple textual key occurrences in a simple fixture, but the team still needs to resolve whether those records represent valid distinct versions.
- 03
Make ambiguity fail visibly before use
Create two harmless rows with the same lookup key and different filenames, then inspect which one the proposed formula returns. Reverse their order in the duplicate and observe why a plausible filename is weak proof. Use an explicit ambiguity gate or a genuinely unique approved key before the result is used for a replacement assignment. Retain source history under its own policy. Do not hide a missing or duplicate match behind a default filename that could silently assign the wrong person.
A concrete example
Unexecuted fixture: A2:A4 contains k1, k1 and k2; B2:B4 contains portrait-old.jpg, portrait-approved.jpg and portrait-other.jpg. E2 contains k1. The proposed =XLOOKUP(E2,A2:A4,B2:B4,"Missing",0,1) returns the first exact match under its search policy, not a guarantee of approval. XLOOKUP is unavailable in Excel 2016 and 2019; verify the recipient’s edition before adopting this formula.
Production ledger native-contract worksheet
| Contract | Proposed proof | Reject when |
|---|---|---|
| Cardinality | Inspect all matching source records | Exact matching is treated as uniqueness |
| Selection | Use different fixture filenames | Row order silently decides approval |
Before you call it ready
- Define whether each lookup key must identify exactly one record.
- Inspect search order as well as exact matching.
- Reject ambiguous assignments before using the returned filename.
When to stop or choose another method
Stop when duplicate meaning or version approval is unresolved. Keep both records and obtain the assignment owner’s decision. Choosing the last match merely because it looks newer is not a substitute for a documented version rule.
