Finding the most recent date that a number matches a certain criteria.

terryfold

New Member
Joined
Jul 16, 2018
Messages
4
Hi there, first time posting so apologies if my etiquette is incorrect.

I'm trying to use index match to find the most recent date that a number is below a specified level. For example, I have the following array:

Col A Col B Col C Col D Col E Col F
ADNAAVAREACR-UAGF/B
03/04/201819.23.9518.311.436.48
04/04/201819.023.9418.7511.336.39
05/04/201819.054.0918.4511.336.52
06/04/201819.074.0118.3611.256.48
09/04/201819.313.9818.2911.266.43

<tbody>
</tbody>

and let's say I would like to identify the most recent date that a number listed below ARE was less than 18.35 - so I would need the formula to return "09/04/2018". How can I do this dynamically?

First, I won't always know which Column I will be in - I will have hundreds of these and so I used match to find the correct column. For example, match("ARE", $1:$1) returned 4, and I know how to do this for every stock I need. I don't know how to incorporate this column result into Index Match.

I then tried index(A2:A6, match(18.35, D2:D6)) and this returns 03/04/2018, but that's not what I'm looking for. If I use a 0 or -1 type of match I get #N/A. This also doesn't incorporate my matching from before for column 4 which I need to have in there for ease of use.

Any advice here? I hope my question is clear. Thank you!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Book1
ABCDEFGHI
1ANDAAVAREACR-UAGF/BStock:ARE
203/04/301819.23.9518.311.436.48Threshold:18.35
304/04/201819.023.9418.7511.336.39Date:09/04/2018
405/04/201819.054.0918.4511.336.52
506/04/201819.074.0118.3611.256.48
609/04/201819.313.9818.2911.266.43
Sheet2
Cell Formulas
RangeFormula
I3{=IFERROR(INDEX($A$2:$A$6,MAX(IF(INDEX($A$2:$F$6,,MATCH($I$1,$1:$1,0))<$I$2,ROW($A$2:$A$6)-ROW($A2)+1))),"Not found")}
Press CTRL+SHIFT+ENTER to enter array formulas.


WBD
 
Upvote 0
ABCDEFGHI
1ANDAAVAREACR-UAGF/BStock:ARE
203/04/301819.23.9518.311.436.48Threshold:18.35
304/04/201819.023.9418.7511.336.39Date:09/04/2018
405/04/201819.054.0918.4511.336.52
506/04/201819.074.0118.3611.256.48
609/04/201819.313.9818.2911.266.43

<tbody>
</tbody>
Sheet2

Array Formulas
CellFormula
I3{=IFERROR(INDEX($A$2:$A$6,MAX(IF(INDEX($A$2:$F$6,,MATCH($I$1,$1:$1,0))<$I$2,ROW($A$2:$A$6)-ROW($A2)+1))),"Not found")}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



WBD

Hi wideboydixon,

Thanks for the response. This worked perfectly for this array, but do you know why it might not carry over properly to a larger array? I thought a sample would be good enough for me to extrapolate for my case, but I actually have an array from C8:SI356, where C8:C356 are the dates and Row 5 (beginning in column D) are the Stocks. When I used the above formula, I'd never get an error but the dates returned wouldn't be correct. It would generally give me April 3, 2018, the first date in the entire array (even if that wasn't the correct case).

I have pre-entered future dates, but I don't see that giving an error as e.g. if the price of ARE was $19.00 today, it'll just fill in every future date.

Is there something I'm missing to extend the formula to a larger/different range? Thank you for your help.
 
Upvote 0
Extend from 12 to 356 and it should be working:


Book1
ABCDEFGH
1Stock:ARE
2Threshold:18.35
3Date:09/04/2018
4
5ANDAAVAREACR-UAGF/B
6
7
803/04/301819.23.9518.311.436.48
904/04/201819.023.9418.7511.336.39
1005/04/201819.054.0918.4511.336.52
1106/04/201819.074.0118.3611.256.48
1209/04/201819.313.9818.2911.266.43
Sheet2
Cell Formulas
RangeFormula
B3{=IFERROR(INDEX($C$8:$C$12,MAX(IF(INDEX($A$8:SI$12,,MATCH($B$1,$5:$5,0))<$B$2,ROW($C$8:$C$12)-ROW($C$8)+1))),"Not found")}
Press CTRL+SHIFT+ENTER to enter array formulas.


WBD
 
Upvote 0
StockThresholdDate
AIM2.00Not Found
ADN AIM
Dates
April 3, 1819.21.68
April 4, 1819.021.61
April 5, 1819.051.58
April 6, 1819.071.6081
April 9, 1819.311.6242
April 10, 1819.351.6678
April 11, 1819.311.73
April 12, 1819.191.69
April 13, 1819.121.7
April 16, 1819.041.72
April 17, 1819.191.75
April 18, 1819.051.69
April 19, 1819.341.71
April 20, 1819.161.76
April 23, 1819.251.77
April 24, 1819.381.75
April 25, 1819.41.96
April 26, 1819.411.9
April 27, 1819.522.072
April 30, 1819.692.21
May 1, 1819.812.09

<tbody>
</tbody>

My formula in C2 is:
{=IFERROR(INDEX($D$8:$D$28,MAX(IF(INDEX($D$8:$E$28,,MATCH($A2, $5:$5,0))<$B2,ROW($D$8:$D$28)-ROW($D8)+1))), "Not Found")}

Before I was getting January 0, 00. I'm now just getting an error. I'm hoping to get April 26, 18 as a result. Any thoughts? Really appreciate your help.
 
Upvote 0

Book1
ABCDEF
1StockThresholdDate
2AIM2April 26, 18
3
4
5ADNAIM
6
7Dates
8April 3, 1819.21.68
9April 4, 1819.021.61
10April 5, 1819.051.58
11April 6, 1819.071.6081
12April 9, 1819.311.6242
13April 10, 1819.351.6678
14April 11, 1819.311.73
15April 12, 1819.191.69
16April 13, 1819.121.7
17April 16, 1819.041.72
18April 17, 1819.191.75
19April 18, 1819.051.69
20April 19, 1819.341.71
21April 20, 1819.161.76
22April 23, 1819.251.77
23April 24, 1819.381.75
24April 25, 1819.41.96
25April 26, 1819.411.9
26April 27, 1819.522.072
27April 30, 1819.692.21
28May 1, 1819.812.09
Sheet1
Cell Formulas
RangeFormula
C2{=IFERROR(INDEX($D$8:$D$28,MAX(IF(INDEX($A$8:SI$28,,MATCH($A$2,$5:$5,0))<$B$2,ROW($D$8:$D$28)-ROW($D$8)+1))),"Not found")}
Press CTRL+SHIFT+ENTER to enter array formulas.



WBD
 
Upvote 0
Assuming the dates are real dates & not text, here is another option.

Excel Workbook
ABCDEF
1StockThresholdDate
2AIM226/04/2018
3
4
5ADNAIM
6
7Dates
83/04/201819.21.68
94/04/201819.021.61
105/04/201819.051.58
116/04/201819.071.6081
129/04/201819.311.6242
1310/04/201819.351.6678
1411/04/201819.311.73
1512/04/201819.191.69
1613/04/201819.121.7
1716/04/201819.041.72
1817/04/201819.191.75
1918/04/201819.051.69
2019/04/201819.341.71
2120/04/201819.161.76
2223/04/201819.251.77
2324/04/201819.381.75
2425/04/201819.41.96
2526/04/201819.411.9
2627/04/201819.522.072
2730/04/201819.692.21
281/05/201819.812.09
Most Recent
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

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