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.

[TABLE="width: 704"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Time[/TD]
[TD]Signal[/TD]
[TD][/TD]
[TD]Max[/TD]
[TD]Min[/TD]
[TD][/TD]
[TD]Time[/TD]
[TD]Signal[/TD]
[TD][/TD]
[TD]Time[/TD]
[TD]Signal[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]0.1[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]-0.025[/TD]
[TD][/TD]
[TD="align: right"]0.3[/TD]
[TD="align: right"]0.2[/TD]
[TD][/TD]
[TD="align: right"]0.3[/TD]
[TD="align: right"]0.2[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]0.2[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0.8[/TD]
[TD="align: right"]0.1[/TD]
[TD][/TD]
[TD="align: right"]0.9[/TD]
[TD="align: right"]0.2[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: right"]0.3[/TD]
[TD="align: right"]0.2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0.9[/TD]
[TD="align: right"]0.35[/TD]
[TD][/TD]
[TD="align: right"]1.4[/TD]
[TD="align: right"]-0.1[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD="align: right"]0.4[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]0.15[/TD]
[TD][/TD]
[TD="align: right"]1.75[/TD]
[TD="align: right"]-0.25[/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD="align: right"]0.5[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]1.4[/TD]
[TD="align: right"]-0.1[/TD]
[TD][/TD]
[TD="align: right"]2.4[/TD]
[TD="align: right"]0.3[/TD]
[/TR]
[TR]
[TD="align: right"]7[/TD]
[TD="align: right"]0.6[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]1.7[/TD]
[TD="align: right"]-0.2[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]8[/TD]
[TD="align: right"]0.7[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]1.8[/TD]
[TD="align: right"]-0.3[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]9[/TD]
[TD="align: right"]0.8[/TD]
[TD="align: right"]0.1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]2.4[/TD]
[TD="align: right"]0.3[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]10[/TD]
[TD="align: right"]0.9[/TD]
[TD="align: right"]0.35[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]11[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]0.15[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]12[/TD]
[TD="align: right"]1.1[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]13[/TD]
[TD="align: right"]1.2[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]14[/TD]
[TD="align: right"]1.3[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]15[/TD]
[TD="align: right"]1.4[/TD]
[TD="align: right"]-0.1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]16[/TD]
[TD="align: right"]1.5[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]17[/TD]
[TD="align: right"]1.6[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]18[/TD]
[TD="align: right"]1.7[/TD]
[TD="align: right"]-0.2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]19[/TD]
[TD="align: right"]1.8[/TD]
[TD="align: right"]-0.3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]20[/TD]
[TD="align: right"]1.9[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]21[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]22[/TD]
[TD="align: right"]2.1[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]23[/TD]
[TD="align: right"]2.2[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]24[/TD]
[TD="align: right"]2.3[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]25[/TD]
[TD="align: right"]2.4[/TD]
[TD="align: right"]0.3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]26[/TD]
[TD="align: right"]2.5[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
</tbody>[/TABLE]


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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,223,214
Messages
6,170,777
Members
452,353
Latest member
strainu

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