Introduction
Fuzzy Lookup, Partial Text Lookup, Approximate Match Lookup, and Wild Card Lookup are all synonyms for two different types of lookup. The first situation is that we have "Coca Cola" and we need to find a match in this case, "Coca Cola Inc.," and return "Atlanta." The lookup value is the sub text string, and the item we're trying to match is the full text string down here. The second situation is the reverse: the lookup value is the full text string, but we need to match it with a sub text string and return the gender.
Understand the two different Fuzzy Lookup, or Partial Text Lookup situations. Which one do you have?
Now, for each type of lookup, we'll see how to do it with the new Microsoft 365 and how to do it the old school way.
XLOOKUP Function Spilled Array Formula. Find "Coca Cola" in "Coca Cola Inc." Microsoft 365 Excel. Any Version of Excel.
If you have Microsoft 365 Excel, we get to use XLOOKUP. For the lookup value, we're going to put in "Coca Cola," but the problem right now is that XLOOKUP needs to know there might be some text before and after this text. The way we do that is with a wild card. We need to use the asterisk character, which represents zero or more characters. The question mark, which we're not going to use here, represents a single character. Since we're going to join it to that cell reference, we have to put it in double quotes, so asterisks and double quotes, and then join it to the relative cell reference. Then we do it on the other side. The beauty of this wild card is that since it represents zero or more characters, it can be straight "Coca Cola" or any number of characters before or after.
Now, comma, lookup array: we want to try to find a match in that column. Comma, return array: we're trying to get the city. Comma, and if not found: that's directly inside of XLOOKUP. In the old days with VLOOKUP, we'd have to use an IFNA function or even the older approach of a straight IF. So I'm going to put in double quotes "not found." Then comma, the fourth argument, match mode exact. Actually, these two are what we use for approximate match lookup, which is when we have tax rates or commission rates. This is a loose synonym that sometimes people use for partial text lookup or fuzzy lookup, but for us we want two that will allow this XLOOKUP function to understand that we want to use a wildcard. The last argument we don't need, so I'm not going to put that argument in, and I'll close parentheses.
If I Ctrl+Enter, that just puts the formula in the cell and keeps the cell selected. That works perfectly, but if we have Microsoft 365 Excel, press F2 to put it back in edit mode. Instead of locking both of these and using a relative cell reference, we'll just give it all four values. That instructs XLOOKUP to spill all four answers, so we avoid having to lock and we avoid having to manually copy. Now when I Control+Enter, it spills down the column. Anytime you use a spilled array, the formula only lives in the top cell. You'll notice all the cells below are grayed out.
Spilling Formulas in Microsoft 365 Excel.
All right, old school. We can use VLOOKUP, and we use our wild card and join it on both sides. Comma, table array: we have to have the whole table, and we have to lock it, so I hit the F4 key. Comma, column index number: the thing I want to go get and bring back to the cell is in the second column, so I type a 2. Comma, we're doing exact match, so we either put FALSE or zero. Close parentheses, Control+Enter, double-click, and send it down. Since VLOOKUP doesn't have an argument for what to put in the cell if there's an error, press F2. In 2007 or later, you can use IFERROR; in 2013 or later, you can use IFNA. It will check whatever that is, and if it's an N/A, then at the end we just put whatever we want. I'm going to put "not found" in double quotes, Control+Enter, double-click, and send it down.
VLOOKUP and IFNA functions. Find "Coca Cola" in "Coca Cola Inc."
That's how to go from a sub text string to the full text string. If we want to do the reverse, meaning the text we have is bigger than the text over here, we can't use a wildcard, but we can use the SEARCH function. The SEARCH function normally takes a single text item, like "John," in find text, and then within text we point it to this item. But find text is where we give it a function argument array operation. We give it all three values, so if it finds one, it'll tell us the position, meaning "John" was found within here. That would be position one, two, three, four, five, and then the other two will get errors. That pattern of positions or errors will help us pick the item from the second column. Then, comma, and within text, we'll have the full text string. If I close parentheses and hit the F9 key, there's our pattern of errors and positions. What are we interested in? The numbers, and notice the numbers in the first position, which is exactly the gender we need to bring back. Control+Z, number at the end, close parentheses, F9. Now we have a pattern of TRUEs and FALSEs.
There are a few things we can do here in Microsoft 365. I'm going to use FILTER, and I want to filter this range right here. Comma, and then the include argument: that's the pattern of TRUEs and FALSEs. Then at the end, say "not found." If I Control+Enter, that works, but I can't do a function argument array operation here, because then I'm working with two different size arrays and it doesn't like that. In this case, we'll leave that as relative. Come back here, click on find text to highlight the whole argument, and then hit the F4 key. Sometimes the problem is that when you come back and hit F4, it only locks one of them, so the safe thing is to select the whole range using the screen tip and then hit F4. Now I can Control+Enter, double-click, and send it down. Last cell: F2, then Escape.
FILTER, SEARCH and ISNUMBER functions. Find "Coca Cola Inc." in "Coca". Microsoft 365 Excel.
We could also use XLOOKUP. If I copy, I'm using the screen tip to select everything so I can easily copy it: Control+C. I like FILTER better, but we could use XLOOKUP and look up TRUE, comma, Control+V within that range there, comma, and there's our return range, F4, comma, and if not found, something in a message, in double quotes, close parentheses. Control+Enter, double-click, and send it down.
XLOOKUP, SEARCH and ISNUMBER functions Find "Coca Cola Inc." in "Coca". Microsoft 365 Excel.
For the old school approach, we're going to use the classic approach: equal sign, Control+V. We'll use MATCH, the old MATCH, because we're assuming we're in the old school. We'll look up TRUE, comma, within there, comma, 0 for exact match. That will give us the relative position. Then we have to use that inside of INDEX, since we're trying to get these values here: F4, comma, and then there's the row number, close parentheses. Control+Enter, double-click, and send it down.
This is a case where we could use IFERROR or IFNA, but it is not efficient, because IFERROR and IFNA always have to run the whole formula in these circumstances. If you can find an alternative logical test that is shorter than running the whole formula, then it's more efficient to use the IF function with that logical test. We want to highlight and select just the SEARCH part, because we can use that with Control+C inside of IF in the first argument, logical test. Control+V, comma. Just for a second, remember F9: what does that give us? An array of numbers and errors. What happens when there's no match? It's all errors. Control+Z. The COUNT function can count how many numbers there are, and it will not be bothered by the fact that they're errors. In our case, it will deliver either one or zero. If I select it and hit F9, we get a one down here, or we'll get a zero, which will be interpreted as FALSE. If it's a non-zero number, it'll run that; otherwise, at the end, comma, in double quotes, "not found," close parentheses. Control+Enter, double-click, and send it down.
INDEX, MATCH, SEARCH, ISNUMBER, IF and COUNT functions. Find "Coca Cola Inc." in "Coca". Any Version of Excel.
That was a bit of fun with old school and new school. When we have the full text string and we want to look up and match some sub text string, we saw how to use XLOOKUP with a wild card, or VLOOKUP with a wild card, when the lookup value is the sub text string and the item to match is the full text string. When the situation is reversed, we saw how to use SEARCH with FILTER, XLOOKUP, or INDEX and MATCH.
When you should NOT use IFERROR or IFNA.
Summary, Closing and Video Links
If you liked that video, be sure to click that thumbs up, leave a comment, and subscribe, because there's always lots more videos to come from excelisfun. If you want to check out some videos about more lookup tricks, there are some links provided in the video description.
