Skip to content
Astera Technology

Stop a Calc lookup when its key matches twice

Count exact key matches before choosing a return value.

Download complete case notes and answer keys ↓

Work with the example

Which of the two K1 page counts should a report use? The worksheet deliberately supplies K1 twice with different counts. H5 counts exact matches. I5 blocks ambiguous retrieval rather than silently choosing the first row.

Supplied exercise data
KeyPages
K112
K28
K115

Edit the working cells

H5 uses =IF(G5="";0;COUNTIF(A5:A7;G5)). I5 gives Choose key for blank, Key missing for 0 matches, Key ambiguous for more than 1, and INDEX/MATCH only for 1. Change A7 to K3: H5 becomes 1 and I5 returns 12. A fresh K9 gives Key missing; clear G5 for Choose key. These are plain whole-cell keys.

Check the failure case

J5’s first-match lookup returns 12 at baseline, concealing the other 15. Do not delete a source row just to make a lookup unique; first determine which source record is intended.

Does “Key ambiguous” establish that two rows describe the same person?

Show the worked answer

No. It only shows that the chosen worksheet key has more than one exact match.

Example files

Related resources