finding 1 value from Median

SeliM

Board Regular
Joined
Aug 10, 2023
Messages
51
Office Version
  1. 365
Platform
  1. Windows
Thank you for taking time to read my question
Is there an approach through Excel formula to find the next value above and below the median?

I am building a system for clinical governance analysis of clinical events and trying to find the values above and below median for demonstration of trends\patterns to hospital Board. (Current range of values is for 3 years (36 values))

Any advice would be appreciated

R
G
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
This is a very long approach -but should help you understand it better

I assume the original range is not sorted

Attributes.xlsx
BCDEF
1RangeMedianClosest-belowClosest-Above
25191721
316
421
534
625
728
88
914
1010
1116
1224
1328
147
1529
1635
1717
1820
19
Sheet2
Cell Formulas
RangeFormula
D2D2=MEDIAN(B2:B17)
E2E2=LET(rng,B2:B17,IF(ISEVEN(COUNT(rng)),INDEX(SORT(rng),COUNT(rng)/2),INDEX(SORT(rng),INT(COUNT(rng)/2))))
F2F2=LET(rng,B2:B17,IF(ISEVEN(COUNT(rng)),INDEX(SORT(rng),COUNT(rng)/2+1),INDEX(SORT(rng),INT(COUNT(rng)/2+2))))
 
Upvote 0
How about:
Book1
BCDEF
1RangeMedianClosest-belowClosest-Above
25181721
316
421
534
625
728
88
914
1010
1116
1224
1328
147
1529
1635
1717
1818
Sheet1
Cell Formulas
RangeFormula
D2D2=MEDIAN(B2:B18)
E2E2=MAX(IF(B2:B18<D2,B2:B18))
F2F2=MIN(IF(B2:B18>D2,B2:B18))
 
Upvote 0
A simplified version of @Momentman's formula, plus an alternative producing different results (depending on what is meant by "values above and below")

ABCDEF
1RangeMedianClosest-belowClosest-Above
25191919
3161624
419
534
625
728
88
914
1010
1116
1224
1328
147
1529
1635
1719
Sheet1
Cell Formulas
RangeFormula
D2D2=MEDIAN(B2:B17)
E2:F2E2=LET(rng,B2:B17,INDEX(SORT(rng),{0,1}+COUNT(rng)/2))
E3E3=MAX(FILTER(B2:B17,B2:B17<D2))
F3F3=MIN(FILTER(B2:B17,B2:B17>D2))
Dynamic array formulas.
 
Upvote 0
Thank you ever so much Momentum - well above my skill level!
I have been able to replicate using your data in column format however the data i work with is in row format (easy I though simply change the data range!)
Reset data range to J4:Z4

The result is different:
MedianClosest Value BelowClosest Value Above
20​
14​
16​

The only change is the range:
=LET(rng,$J$4:$Z$4,IF(ISEVEN(COUNT(rng)),INDEX(SORT(rng),COUNT(rng)/2),INDEX(SORT(rng),INT(COUNT(rng)/2))))
=LET(rng,$J$4:$Z$4,IF(ISEVEN(COUNT(rng)),INDEX(SORT(rng),COUNT(rng)/2+1),INDEX(SORT(rng),INT(COUNT(rng)/2+2))))

Is there something I have missed.
R
G
 
Upvote 0
Kinda curious how the simpler options did not work for you?

Book1
DEFGHIJKLMNOPQRSTUVWXYZ
1MedianClosest-belowClosest-Above
2181721
3
4Range5162134252881410162428729351718
Sheet1
Cell Formulas
RangeFormula
D2D2=MEDIAN(J4:Z4)
E2E2=MAX(IF(J4:Z4<D2,J4:Z4))
F2F2=MIN(IF(J4:Z4>D2,J4:Z4))
 
Upvote 0
Solution
Many thanks to you all for guiding me through this challenge.

Very much appreciated and I admire your expertise.:)

Actually the simpler version did work for me - when I got my ranges sorted out :(

R
G
 
Upvote 0
Thanks Cubist - brilliantly simple
Didn't think about it because my mind doesn't work quite like that apparently:)
Have a terrific day
R
G
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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