I have many tables with two columns (key-value style) and I want to combine all the values in a single table. I lookup key in a first column and insert a value from the second one. I've encountered an issue when a wrong key is looked up. Here is a simple example:
The RBYourselfNotUsedRule
is not present in Table 1 and 271 belongs to RBVariableReferencedOnceRule
. Does anybody have an idea why RBVariableReferencedOnceRule
was looked up for RBYourselfNotUsedRule
?
Best Answer
If the
LOOKUP
function can't find thesearch-for
value, the function matches the largest value insearch-where
that is less than or equal tosearch-for
. This is why, when the formula cannot find the match, it returns the closest thing it can find.From Apple's Documentation:
When opting for the exact match, you could wrap the formula in a
IFERROR()
function to catch the "no match" error and return whatever you specify. i.e.:""
empty string or other message."No Match"
as a example.You may need to use the more powerful function
VLOOKUP()
.Example:
A more powerful combination of functions to perform lookups is
INDEX(MATCH())
. [This function gives much more power for looking up references without having to know the exact column number.] For more information and an example, see Using INDEX MATCH for Advanced Lookups | Deskbright. Even though this reference is for Excel, Numbers supports these functions just as well.