Finding max value in a range based on a certain row

jungle125

New Member
Joined
Nov 5, 2022
Messages
18
Office Version
  1. 365
Platform
  1. Windows
Hi

With help from this forum, I have identified the low value in a range of 20 rows below my point of interest (identified in column I by the value 1) using an XLOOKUP and MIN function in column J. In the example the point of interest is in row 141, and the identified low point (from column D) is in row 160. However, now I would like to know what the maximum value (in column C) of the 40 rows succeeding the identified low (in other words from row 160). The trouble I´m having is that the row of the low point is dynamic, it can be any of the rows in the defined 20-row range in the initial XLOOKUP formula, so I can´t define the xlookup range by a fixed offset. Keep in mind that these formulas are applied to up to 10,000 lines of datapoints, this is just an example of one identified row of interest. If the formula works, the row that should be returned is row 182, corresponding to the high value of 4.2 (highlighted in yellow, cell C182).

Thanks in advance for any help!



LAC.TO.xlsx
ABCDEFGHIJKL
2DateOpenHighLowCloseAdj CloseVolume% Difference between HH and LL last 42 daysPoint of InterestRow of Flag LowRow of highest within 40 days of flag lowHigh Point (Column C)
14103/02/20094.554.94.44.54.5700007911160
14204/02/20094.454.54.254.54.520780718  
14305/02/20094.54.54.254.354.3519500718  
14406/02/20094.34.354.054.254.2517560691  
14509/02/20094.254.253.954.14.121160608  
14610/02/20094.34.444.054.0523360633  
14711/02/20094.254.2544.054.056380507  
14812/02/20094.054.253.853.853.8523580507  
14913/02/2009443.83.83.811280471  
15017/02/20093.7543.753.753.7523640471  
15118/02/20093.7543.753.953.953220471  
15219/02/2009443.83.93.99820471  
15320/02/20093.93.93.63.853.8510480457  
15423/02/20093.8543.73.73.718480471  
15524/02/20093.73.753.53.753.755820436  
15625/02/20093.753.753.63.753.758440436  
15726/02/20093.63.73.553.73.75880429  
15827/02/20093.553.753.53.53.517680317  
15902/03/20093.653.653.33.43.419120204  
16003/03/20093.453.453.153.153.1542460188  
16104/03/20093.353.453.253.43.45320188  
16205/03/20093.53.53.153.253.2515380100  
16306/03/20093.253.252.852.92.95110086  
16409/03/20093.153.152.752.752.754268050  
16510/03/20092.82.82.652.72.7910022  
16611/03/20092.92.952.72.752.751520028  
16712/03/20092.952.952.652.652.651390026  
16813/03/20092.7532.752.952.952260020  
16916/03/20092.9532.852.852.85900013  
17017/03/20092.952.952.72.72.71416011  
17118/03/20092.92.92.82.92.9181009  
17219/03/2009332.52.52.59484013  
17320/03/20092.652.652.52.52.5186006  
17423/03/20092.452.452.42.452.4581300-2  
17524/03/20092.42.42.352.42.4306800  
17625/03/20092.42.652.22.52.511836013  
17726/03/20092.652.72.62.72.71310023  
17827/03/20092.72.72.72.72.7023  
17930/03/20092.82.82.652.82.8568027  
18031/03/20092.83.052.83.053.054502039  
18101/04/20093.153.8533.853.8525398075  
18202/04/20093.84.23.653.953.953476091  
18303/04/20093.9543.753.93.91784082  
18406/04/20093.753.753.253.453.451064070  
18507/04/20093.353.353.13.23.21250052  
18608/04/20093.13.23.13.13.1284045  
18709/04/20093.153.23331492045  
18813/04/20093.053.533.453.451026059  
18914/04/20093.453.453.253.353.351068057  
19015/04/20093.53.53.253.253.253156059  
19116/04/20093.43.43.23.23.2788055  
19217/04/20093.23.453.23.253.252466057  
19320/04/20093.253.653.13.253.25810066  
19421/04/20093.153.152.952.952.951990043  
19522/04/20093.053.052.752.752.751530039  
19623/04/20092.852.852.752.82.81618030  
19724/04/20092.82.92.72.92.92376032  
19827/04/20092.832.733786036  
19928/04/2009332.752.92.9108036  
20029/04/20092.752.92.752.92.92076032  
Sheet1 (2)
Cell Formulas
RangeFormula
H141:H200H141=(C141-MIN(D99:D140))/MIN(D99:D140)*100
I141:I200I141=IF(AND(H141>=100,H141=MAX(H131:H151)),1,"")
J141:J200J141=IF(I141=1,XLOOKUP(MIN(D142:D161),D142:D161,ROW(A142:A161),,,-1),"")
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Do you specifically need to show the row in column K?

I've included a 2 part formula with the row returned in column K, then referenced that in column L to get the final result. I've also added another formula in column M that gets the final result of 4.2 directly from the row of interest without the need for column K as a helper.

Book1
JKLM
2Row of Flag LowRow of highest within 40 days of flag lowHigh Point (Column C)Alt High Point formula
1411601824.24.2
Sheet2
Cell Formulas
RangeFormula
J141J141=IF(I141=1,INDEX(ROW(A142:A161),MATCH(MIN(D142:D161),D142:D161,)),"")
K141K141=IF(J141="","",LET(r,INDEX(C:C,J141):INDEX(C:C,J141+40),INDEX(ROW(r),MATCH(MAX(r),r,0))))
L141L141=IF(K141="","",INDEX(C:C,K141))
M141M141=IF(J141="","",LET(r,INDEX(C:C,J141):INDEX(C:C,J141+40),INDEX(r,MATCH(MAX(r),r,0))))
 
Upvote 0
Another option:

Book1
JKL
2Row of Flag LowRow of highest within 40 days of flag lowHigh Point (Column C)
1411601824.2
Sheet9
Cell Formulas
RangeFormula
J141J141=IF(I141=1,XLOOKUP(MIN(D142:D161),D142:D161,ROW(A142:A161),,,-1),"")
K141K141=IF(I141="","",LET(r,INDEX(C:C,J141):INDEX(C:C,J141+40),XLOOKUP(L141,r,ROW(r),,0,-1)))
L141L141=IF(I141="","",MAX(INDEX(C:C,J141):INDEX(C:C,J141+40)))
 
Upvote 0
Solution
I'm still asking myself why I thought it was necessary to match the max of the range to the range in order to return the same max (in the alt formula in my suggestion) 😵‍💫
 
Upvote 0
I'm still asking myself why I thought it was necessary to match the max of the range to the range in order to return the same max (in the alt formula in my suggestion) 😵‍💫
Yeah, I wondered that too! ;) But I've done things like that before, you work your way to something that works, and don't realize there's a better way. Just chalk it up to being late on a Saturday night.
 
Upvote 0
I don't think I even looked at it properly, I remember thinking that removing the ROW() function from the formula in K141 would allow the formula to pull the result directly from the array without needing to get the row number first. I certainly didn't pay any attention to the other steps.
Just chalk it up to being late on a Saturday night.
In all honesty, it was just me not paying attention to what I was doing, but I'll take any excuse that makes it sound a bit better :)
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,124
Members
453,021
Latest member
Justyna P

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