Approximate Lookup

Jon von der Heyden

MrExcel MVP, Moderator
Joined
Apr 6, 2004
Messages
10,912
Office Version
  1. 365
Platform
  1. Windows
Hello

I'm struggling to think of a 'not so complicated' way of achieving similar to an approximate VLOOKUP.

I have a large table, and one of its' many fields is 'Days Overdue', which can be any integer greater than zero. I would like to update another existing field called 'Aged Bucket' to categorise each record according to 'Days Overdue'.

In excel I am lucky enough to be able to perform an approximate lookup, e.g:

=LOOKUP(F4,{0,"0-30 Days";31,"31-60 Days";61,"61-90 Days"})

Where F4 houses the 'Days Overdue'. E.g: If 'Days Overdue' = 34 then it should return "31-60 Days".

I would like to do similar but I would like to store the age categories in a table. I would like to avoid a big hiddeous expression if possible.

Suggestions gratefully received! Thanks. :)
 
If they are regular 'buckets', you might use the Partition function in a query rather than a table?
 
Upvote 0
If it was me, I might look at creating a User Defined Function to do this, especially using CASE SELECT statements. I find those are much easier to read and maintain than some really long, big query expression, and if you re-use it in other queries, you only need to update it in one place.
 
Upvote 0
Rory, unfortunately the buckets are not all at regular intervals and I need to return specific strings. But thanks alot anyway because that is a handy function to know of.

Joe4, thanks that is probably the way I will have to go.

Cheers :)
 
Upvote 0
OK, the usual other way to do it is with a subquery - see example(s) here.
 
Upvote 0
I created a function to loop through a lookup table and return the corresponding bucket according to the Days Overdue. Works a treat and users can simply manage the table if they want to change bucket values.

Thanks :)
 
Upvote 0
Forgot about that method.
Don't have the need to use it much myself (seldom do approximate matches), but that is a very good way to go about it.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top