INDEX,MATCH with Greater Than Date Criteria

coloradobstime

New Member
Joined
Dec 23, 2011
Messages
3
Good Morning! I found this thread here (http://www.mrexcel.com/forum/excel-questions/785753-index-match-greater-than-date-criteria.html) which is closely related to my issue but cannot figure out how to remove the "third criteria" from the formula in order to make it work for my problem. I utilize a program that uses "Dated Constant" variables which means it will utilize the value of that variable until the next change. I need to take similar logic to this in a spreadsheet I have for post-analysis. I will ensure the data set I am referencing has the appropriate values prior to the period I am looking at. As an example, the Folly1 unit minimum will be 120 past 01/01/2016 until the next change that occurs on 04/01/2016 which will move it to 105 until the next change.... so between January 1, 2016 and March 31, 2016 at 11:59:59 it remains 120 at 04/01/2016 12:00am it changes to 105.

Spreadsheet:

Excel 2012
ABCDEFGHIJKLMNOP
1DataLookupsExpected return value:
2DateUnitMinimum CapacityDateUnitQuantityMinimum Capacity for Period Only
31/1/2016Cat01/1/2016Folly1202120
41/1/2016Dog131/2/2016Folly1700120
51/1/2016Dog234/1/2016Folly11201105
61/1/2016Dog334/2/2016Folly11201105
71/1/2016Elephant 528
81/1/2016Elephant 645
91/1/2016Elephant 6s45*Data will be sorted by Unit and then by Date
101/1/2016Elephant 780
111/1/2016Elephant 7s80One match type is an exact match column b to column g.
121/1/2016Folly1120
134/1/2016Folly1105Second match type is 1 - Less than (largest value less than or equal to) column a to column f
1410/1/2016Folly1120
154/1/2017Folly1118
1610/1/2017Folly1120Expected to: Find unit in data (column b) that matches unit in lookups (column g), then find the latest date (column a) less than or equal to date listed in lookups (column f) and return minimum capacity (column c) to column I.
174/1/2018Folly1105
1810/1/2018Folly1120Have tried:
194/1/2019Folly1105Works for exact date match:
2010/1/2019Folly11201/1/2016Folly1202120
214/1/2020Folly11054/1/2016Folly1121105
2210/1/2020Folly11204/1/2017Folly1700118
234/1/2021Folly1105
2410/1/2021Folly1120Does not work for between two dates….
251/1/2016Folly22001/2/2016Folly1202#N/A
26
27Reason: the match type is defined as type "0" for both…
28=INDEX($A$1:$C$25,MATCH(1,($B$1:$B$25=G25)*($A$1:$A$25=F25),0),3)
29
30Seen this post:
31http://www.mrexcel.com/forum/excel-questions/785753-index-match-greater-than-date-criteria.html
32but cannot figure out how to remove third criteria…

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2



I am trying to:
Expected to: Find unit in data (column b) that matches unit in lookups (column g), then find the latest date (column a) less than or equal to date listed in lookups (column f) and return minimum capacity (column c) to column I.

Thanks for pointing me in the right direction!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try:
This is an array formula and must be entered with CTRL-SHIFT-ENTER.
Excel Workbook
ABCDEFGHI
1Data****Lookups**Expected return value:
2DateUnitMinimum Capacity**DateUnitQuantityMinimum Capacity for Period Only
31/1/2016Cat0**1/1/2016Folly1120120
41/1/2016Dog13**1/2/2016Folly1120120
51/1/2016Dog23**4/1/2016Folly1105105
61/1/2016Dog33**4/2/2016Folly1105105
71/1/2016Elephant 528******
81/1/2016Elephant 645******
91/1/2016Elephant 6s45******
101/1/2016Elephant 780******
111/1/2016Elephant 7s80******
121/1/2016Folly1120******
134/1/2016Folly1105******
1410/1/2016Folly1120******
154/1/2017Folly1118******
1610/1/2017Folly1120******
174/1/2018Folly1105******
1810/1/2018Folly1120******
194/1/2019Folly1105******
2010/1/2019Folly1120******
214/1/2020Folly1105******
2210/1/2020Folly1120******
234/1/2021Folly1105******
2410/1/2021Folly1120******
251/1/2016Folly2200******
Sheet
 
Upvote 0
Wow, that is really awesome! I'm going to try and walk myself through that monster of a formula to see if I can understand what it is doing. The absolute values look intriguing. Thank you so much for the help - I don't think even if I threw another 20 hours at it I would have come to a solution.
 
Upvote 0
You're welcome. Thanks for the feedback.

This part of the formula:
Code:
IF($B$3:$B$25=$G3,IF($A$3:$A$25<=$F3,ABS($A$3:$A$25-$F3)))
Looks for a match in column B unit for the item in G3. It then looks for the dates in column A that are less than or equal to the date in F3, it then subtracts the date in F3 from each of those values and returns the following array:
{FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;0;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}
In this case we had an exact match in row 10 which shows up as a 0.

When we put a MIN function in front of the formula it returns the 0.

So the MATCH function looks for the 0 and finds it in row 10 and returns a 10 to the INDEX.
So this part of the formula just returns the row that matches the criteria.
Code:
[MATCH(MIN(IF($B$3:$B$25=$G3,IF($A$3:$A$25<=$F3,ABS($A$3:$A$25-$F3)))),IF($B$3:$B$25=$G3,IF($A$3:$A$25<=$F3,ABS($A$3:$A$25-$F3))),0)/CODE]

Hope that helps some.
 
Upvote 0

Forum statistics

Threads
1,215,352
Messages
6,124,455
Members
449,161
Latest member
NHOJ

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