Looking up to a table with a non-exact date (effective date)

borntorun75

Board Regular
Joined
Jul 12, 2010
Messages
57
Hi,

I'm trying to do a lookup / match based on both on specific criteria (Product and Type), but also on a date that isn't exact.

Here is a sample of the table. It's a list of products, types and Effective Price Dates.

ABCD
ProductTypeEffective Price DatePrice
HatsBobble01/01/200020.00
HatsBobble01/04/201025.00
HatsBaseball01/01/200015.00
ShirtBlue01/01/200012.00
T-ShirtSpotted01/01/20007.50

<tbody>
</tbody>


I'd like to do a lookup based on the first 3 input contents, and do a lookup/match to the price. The issue is that the price can be based on an Effective Date that isn't in the source data. So, while I want to have an exact match on the Product and Type, the Price Date in the table is an effective date. The formula result of the lookup/match is shown in red.

The first 2 examples below work fine as they have exact matches to the table.

The next 2 examples, however, have an Input Price Date that isn't in the table. So, the lookup needs to have that flexibility to work on a principal of on/after the date in the table.

The final example is for a product that doesn't exist in the table. So, accordingly, I'd need to trap that.

I'm trying to achieve this in formula rather than VBA.

Input ProductHats
Input TypeBobble
Input Price Date01/01/2000
Price (lookup)20.00
Input ProductHats
Input TypeBobble
Input Price Date01/04/2010
Price (lookup)25.00
Input ProductHats
Input TypeBobble
Input Price Date31/03/2009
Price (lookup)20.00
Input ProductHats
Input TypeBaseball
Input Price Date20/10/2010
Price (lookup)15.00
Input ProductHats
Input TypeRain
Input Price Date01/02/2010
Price (lookup)#N/A

<tbody>
</tbody>

Any suggestions would be appreciated. For the table above, I can use helper columns to work a solution. I have flexibility.

I've tried using an INDEX / MATCH formula, but I can't get it to work with that effective date.

Best regards, Mike
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
The following assumes that the original table is in A1:D6, the product to search in F2, the type in G2 and the date in H2. You also need to make sure that the dates in the table are sorted from earliest at the top to latest at the bottom (which makes sense as you add new prices)

=LOOKUP(2,1/(($A$2:$A$6=F2)*($B$2:$B$6=G2)*($C$2:$C$6<=H2)),$D$2:$D$6)
 
Upvote 0
The following assumes that the original table is in A1:D6, the product to search in F2, the type in G2 and the date in H2. You also need to make sure that the dates in the table are sorted from earliest at the top to latest at the bottom (which makes sense as you add new prices)

=LOOKUP(2,1/(($A$2:$A$6=F2)*($B$2:$B$6=G2)*($C$2:$C$6<=H2)),$D$2:$D$6)

Thank-you so much. This works beautifully from what I've seen. I note your comment about dates being in order - absolutely that would be the case. The data table itself, in my spreadsheet, is a pivot table which by default would sort the dates into ascending order. It's right to point it out though of course.

Thanks so much 'steve the fish' - this is exactly what I was looking for.

best regards, mike
 
Upvote 0

Forum statistics

Threads
1,215,353
Messages
6,124,464
Members
449,163
Latest member
kshealy

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