find nth larger number (that is not blank) and nth smaller number (that is not blank)

ellison

Active Member
Joined
Aug 1, 2012
Messages
356
Office Version
  1. 365
Platform
  1. Windows
Hi, have been searching around but can't quite find something that I can apply to an issue we would like to crack!

We are trying to find a way to find the closest 3 smaller numbers and closest 3 larger numbers in our "Raw Data" compare to our "Work in Progress Data".

I've set out a working example below which shows the "Raw Data" and "WIP data" and what the answers should hopefully be.

(If it helps, we are on Microsoft 365 and the list should be about 20K rows.)

Raw Data
1
3
7
15
20


WIP_DataNext Higher in the Raw Data2nd Higher in the Raw Data3rd Higher in the Raw DataNext Smaller in the Raw Data2nd Smaller in the Raw Data3rd Higher in the Raw Data
13715#n/a#n/a#n/a
2715201#n/a#n/a
67152031#n/a
141520#n/a731
1820#n/a#n/a1573
25#n/a#n/a#n/a20157
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
How about this?

Book1
ABCDEFGHI
1Raw DataWIP_DataNext Higher in the Raw Data2nd Higher in the Raw Data3rd Higher in the Raw DataNext Smaller in the Raw Data2nd Smaller in the Raw Data3rd Higher in the Raw Data
2113715#NUM!#NUM!#NUM!
33237151#NUM!#NUM!
4767152031#NUM!
515141520#NUM!731
6201820#NUM!#NUM!1573
725#NUM!#NUM!#NUM!20157
Sheet2
Cell Formulas
RangeFormula
D2:F7D2=AGGREGATE(15,6,$A$2:$A$6/($A$2:$A$6>$C2),COLUMNS($D$2:D$2))
G2:I7G2=AGGREGATE(14,6,$A$2:$A$6/($A$2:$A$6<$C2),COLUMNS($D$2:D$2))
 
Upvote 0
How about
+Fluff v2.xlsm
ABCDEFGHI
1RawWIP
2113715n/an/an/a
33237151n/an/a
4767152031n/a
515141520n/a731
6201820n/an/a1573
725n/an/an/a20157
List
Cell Formulas
RangeFormula
D2:F7D2=IFERROR(INDEX(FILTER($A$2:$A$6,$A$2:$A$6>C2),{1,2,3}),"n/a")
G2:I7G2=IFERROR(INDEX(FILTER(SORT($A$2:$A$6,,-1),SORT($A$2:$A$6,,-1)<C2),{1,2,3}),"n/a")
Dynamic array formulas.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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