We all know VLOOKUP (or INDEX+MATCH) as an indispensable tool in our Excel toolbox. But what if you want the lookups to be a little gentler, nicer and relaxed?
Let’s say you want to lookup the amount $330.50 against a list of payments. There is no exact match, but if we look 50 cents in either direction, then we can find a match. Here is a demo of what I mean.

Unfortunately, you can’t convince VLOOKUP to act nice.
Hey VLOOKUP, I know you are awesome and all, but can you cut me some slack here?
VLOOKUP is tough, reliable and has a cold heart. Or is it?
In this post, let’s learn how to do lenient lookups.
Data for the problem
Let’s say you have a simple 2 column table like this. Our table is uninspiringly named data.

Lenient lookup – setting up the formula
Our input amount is in cell C3.
Let’s say when looking up for the amount, we want to follow this logic.
- If an exact match is found, return that
- Else, see if we can find anything with in 50 cents either side (you can change 50 to whatever you want)
- If nothing can be found, we want to return “Not found” or similar message
Formulas to use:
1: we can use good old INDEX+MATCH
2: we can use array based INDEX+MATCH
3: we can use IFERROR.
Let’s put everything together.
Our lenient lookup formula (array):
=IFERROR( INDEX(data[Client], IFERROR(MATCH($C$3,data[Amount],0), MATCH(1, (data[Amount]>($C$3-0.5))*(data[Amount]<($C$3+0.5)),0) ))
,"Not found")
How does it work?
Let’s go inside out.
MATCH($C$3,data[Amount],0): this formula simply looks for C3 in data[Amount] column and returns the position.
MATCH(1, (data[Amount]>($C$3-0.5))*(data[Amount]<($C$3+0.5)),0): This array formula checks for 1 (TRUE) by looking at data[Amount] between C3-0.5 and C3+0.5
The formula has two Boolean arrays multiplied and it returns a bunch of 1s & 0s.
MATCH then picks up the first such amount.
Inner IFERROR(MATCH(…), MATCH(…)): This acts like a fail-safe switch. If there is no exact match (first one), then lenient match (second one) will be used.
Outer IFERROR(): If no matches are found (exact or lenient) then “Not found” will be printed.
As this is an array formula, you need to press CTRL+Shift+Enter to get the result.
Related material – read these if you have questions about the formula techniques used above:
Other lenient / almost lookup problems
There are few more variations to this technique. Let’s review them.
Note: all of these are array formulas, so press CTRL+Shift+Enter.
Ignore decimal portion
We lookup just the whole number portion of the value to find match.
Formula: =INDEX(data[Client], MATCH(G7, INT(data[Amount]),0))
Notes on how it works:
- INT() turns data[Amount] column to whole numbers.
- We then lookup the amount (G7) and return the match
Amount is at least something, client name begins with S
Formula: =INDEX(data[Client], MATCH(1, (data[Amount]>=G8)*(LEFT(data[Client],1)=”S”),0))
- We use a different Boolean structure with >= and LEFT() formulas. The output will be a bunch of 1s & 0s.
- INDEX+MATCH for find the first such value (G8)
Closest Amount to input
This is interesting. We use MIN & ABS to find closest amount to input value (G10) and return the client’s name.
Formula: =INDEX(data[Client], MATCH(MIN(ABS(data[Amount]-G10)), ABS(data[Amount]-G10),0))
- ABS(data[Amount]-G10) gives a bunch of absolute (positive) values. The smallest of these will closest to G10.
- MIN() finds the smallest value
- MATCH looks up the minimum value from ABS(data[Amount]-G10)
- INDEX gives corresponding client’s name
Download lenient lookup example workbook
Click here to download the example workbook. The file contains sample data, several examples of these techniques and additional resources to learn. Give it a go.
More ways to lookup
Lookups are an essential part of any data analysis work you do in Excel. Pick up some nifty tricks from these links.
- Basics:
- Advanced:
Got a lookup tip to share?
Have some lookup stories to tell? I am listening. Please post them in comments.
















10 Responses to “Multiple Find Replace with Power Query List.Accumulate()”
Note: The text-formula above miss a -1. The video is correct.
😀 sorry, I made the exact same mistake as you did - initially - in the video. {0..3} is one thing, and Table.RowCount(replacements) -->3 items ={0,1,2} is another thing.
1st question : you've created a new column to put the replacements in. how ca we replace in the original column without creating a new one ?
2nd question : how can we replace the value in the entire cell and not only the text (Using ReplaceValue instead of text.Replace) ?
Thanks you in advance
Chandoo, I would be very interested to have your answers in both Yassine's questions!
Thank you for sharing,
Vassilis
Thank you for this! I was just doing an assignment where I was having to replace words with other words in my Excel sheet. We are starting with the basics in my class, so I know I don't have a huge list that I would need to find and replace, but this is something that could be useful down the road for me!
Hi
This is nearly perfect for my needs thank you, however I would like just the "replace" to be the result if possible please, I have tried in vain adjusting the formula without success.
Thank you in advance
Thank you! Awesome tip, and very flexible, too.
My find/replace values were in non-adjacent columns of a table containing a bunch of other data. Worked prefectly and I am now a tiny bit less clueless.
Hi!!!
I have the same question that Yassine did.
I need to replace the values in the same column. I don't want to create a new column e then have to remove the old column.
How could I could that?
That's a real fun article. It inspired me to delve deeper into the topic of List.Accumulate. I can see how the function works, but it takes an additional step to imagine how one can use it for more complex applications.
Your example also made it into my article, together with some other use-cases. Would be great to get your opinion on which other areas you would include in the article.
Let me drop the link to the page so others can too find it for further reading: https://gorilla.bi/power-query/list-accumulate/
Expression.Error: The name 'replacements' wasn't recognized. Make sure it's spelled correctly.