How to extract x/y pairs for minima & maxima below and above defined thresholds? (Excel 2007)

rover8721

New Member
Joined
Jun 23, 2014
Messages
8
Hi,

I'm working with a large data set with paired values. Simply, column A is the x value (time) paired with the neighboring y value (signal) in column B. I'm seeking to only retrieve the x-y pair (in columns G & H, respectively) when y >= a certain threshold for maxima and y <= for minima. I've been able to achieve this with the code shown below (thanks to other similar situations solved by forum users!). The complication I'm running into now is where there are multiple data points for a single peak. Ideally, I'd like to report the average x and y values as a single entry for a situation like this, but even selecting only the pair with the greatest Y magnitude could be acceptable if the other route isn't viable. The most logical approach seems to be only extracting an x-y pair when its magnitude is greater than the data points on either side, but I haven't had any luck writing up such an equation. I've included a table below of a simplified situation, including the equations I've come up with so far and what I'd ideally like the result to look like. Also, it's important to me that there not be any spaces in the output data because of the next manipulations I'll be applying, but it would otherwise be manageable.

I'm fairly new to writing complex equations and the like in Excel, but any guidance would be greatly appreciated!!! Thank you all for reading this!


Sample table where A/B are raw data, D/E are the thresholds for maxima and minima, G/H are the retrieved pairs from the equations listed below, and J/K are the result I'd like to achieve.

ABCDEFGHIJK
1TimeSignalMaxMinTimeSignalTimeSignal
20.100.04-0.0250.30.20.30.2
30.200.80.10.90.2
40.30.20.90.351.4-0.1
50.4010.151.75-0.25
60.501.4-0.12.40.3
70.601.7-0.200
80.701.8-0.300
90.80.12.40.300
100.90.350000
1110.150000
121.100000
131.200000
141.300000
151.4-0.10000
161.500000
171.600000
181.7-0.20000
191.8-0.30000
201.900000
21200000
222.100000
232.200000
242.300000
252.40.30000
262.500000

<tbody>
</tbody>


G2 equation
Code:
=IFERROR(
 INDEX(A$2:A$2402,
  SMALL(
   IF(B$2:B$2402>=D$2, ROW(A$2:A$2402)-ROW(A$2)+1,
    IF(B$2:B$2402<=E$2, ROW(A$2:A$2402)-ROW(A$2)+1
    )
   ),
  ROWS(A$2:A2)
  )
 ),
0)

H2 equation
Code:
=IFERROR(
 INDEX(B$2:B$2402,
  SMALL(
   IF(B$2:B$2402>=D$2, ROW(B$2:B$2402)-ROW(B$2)+1,
    IF(B$2:B$2402<=E$2, ROW(B$2:B$2402)-ROW(B$2)+1
    )
   ),
  ROWS(B$2:B2)
  )
 ),
0)
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,215,064
Messages
6,122,937
Members
449,094
Latest member
teemeren

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