Lookup value against date range to return another value

davidphi

New Member
Joined
Jan 16, 2017
Messages
5
Hi,

I have a similar query to this question:

http://www.mrexcel.com/forum/excel-...-lookup-date-within-multiple-date-ranges.html

But, I think it's not quite the same in my case.

I have a table of data with Value's and Date's eg:

AB
ValueDate
Apple02/07/2008
Orange04/08/2010
Apple08/01/2015

<tbody>
</tbody>

I have a lookup table of Values, Dates and ID's:

ABCD
ValueDate StartDate EndID
Apple01/01/200801/01/20151
Apple02/01/201516/01/20172
Orange01/01/200816/01/20173

<tbody>
</tbody>

I want to lookup the ID of the value within the date range as specified by the date. I've tried

=LOOKUP(2,1/((B2>=LookupTable!B2:B4)*(B2<=LookupTable!C2:C4)),LookupTable!D2:D4)

But, instead of getting the ID 1 for Apple, I get the ID 3 for Orange. I believe this is because it is the first date range, from the bottom up, that matches the date range of date in B2.

What I want to calculate is the following:

ABC
ValueDateID
Apple02/07/20081
Orange04/08/20103
Apple08/01/20152

<tbody>
</tbody>

How can I get it to take in to account the value as well as the date range?

Thanks!

David
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Here's one option. This assumes that you will never have any duplicate Values in the same date range.


Excel 2010
ABCDEFGH
1ValueDateIDValueDate StartDate EndID
2Apple7/2/20081Apple1/1/20081/1/20151
3Orange8/4/20103Apple1/2/20151/16/20172
4Apple1/8/20152Orange1/1/20081/16/20173
Sheet1
Cell Formulas
RangeFormula
C2=SUMIFS(H:H,E:E,A2,F:F,"<="&B2,G:G,">="&B2)
 
Upvote 0
control+shift+enter, not just enter:

=INDEX(LookupTable!$D$2:$D$6,MATCH(1,IF(LookupTable!$A$2:$A$6=A2,IF(B2>=LookupTable!$B$2:$B$6,
IF(B2<=LookupTable!$C$2:$C$6,1))),0))
 
Upvote 0
Awesome - thanks very much. The index solution worked well. I did try this initially, but couldn't work out how to get the correct set of matches.

Thanks for your help!

David
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,397
Members
449,081
Latest member
JAMES KECULAH

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