Eadd22
Eadd22

Reputation: 15

Excel formulas to lookup cost based on city and date

I have a list of cities and product costs that are effective as of the date listed.

I'm trying to make a formula that will return the applicable cost to cell "C" when given an city in "A" and a date in "B". For example, when A is "Cincinnati" and B is "22-Jul-16", C should read "$18.00".

The list is updated and keep in order of effective dates. I was originally thinking CONCATENATE city and date then use a VLOOKUP set to TRUE, but the approximation for the date doesn't work combine them with text so it only returns the cost for the exact date. Guessing this is in the realm of arrays but not too savvy with them.

Open to any suggestion, thanks!

City    Effective Date  Cost        City    Date    Cost
Cincinnati  01-Jan-16    $15.00         A   B   C
Dayton  01-Jan-16    $14.50                 
Atlanta 01-Jan-16    $16.50                 
Dallas  01-Jan-16    $16.00                 
Atlanta 20-Feb-16    $18.00                 
Cincinnati  01-Mar-16    $15.20                 
Dallas  31-Mar-16    $17.00                 
Dayton  12-May-16    $15.00                 
Atlanta 21-Jun-16    $20.00                 
Cincinnati  01-Jul-16    $18.00                 
Dallas  31-Jul-16    $20.00                 
Cincinnati  01-Sep-16    $16.00                 
Dayton  11-Sep-16    $17.00                 
Atlanta 22-Sep-16    $17.75                 
Dallas  01-Oct-16    $16.50                 
Dayton  12-Nov-16    $15.50 

Screenshot: Data Screenshot

Upvotes: 0

Views: 51

Answers (1)

Scott Craner
Scott Craner

Reputation: 152585

You would use this array formula:

=INDEX($C$2:$C$17,MATCH(H2,IF($A$2:$A$17=G2,$B$2:$B$17)))

Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting Edit mode. If done properly then Excel will put {} around the formula.

enter image description here

Upvotes: 2

Related Questions