median...if

Duritz

Board Regular
Joined
Apr 28, 2005
Messages
226
Hi. Like the function "sumif", I need a "medianif" funtion, ie, find the median of a set in column B given that their corresponding figure in A matches a variable.

So, for example:

A B
5 1.2
2 1.4
3 1.4
7 1.2
5 2.3
4 1.6
3 1.5
5 2.2
6 1.1
7 1.9
5 0.9
4 1.9
5 1.7

And if the variable to match is 5, then the figures to find the median of are 1.2, 2.3, 2.2, 0.9 and 1.7, of which of course the median is 1.7.

Any ideas?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Duritz

Try this:
E2: =MEDIAN(IF(A1:A13=E1,B1:B13))
Confirmed with Ctrl+Shift+Enter not just Enter
Mr Excel.xls
ABCDEF
151.2Variable:5
221.4Result:1.7
331.4
471.2
552.3
641.6
731.5
852.2
961.1
1071.9
1150.9
1241.9
1351.7
14
Median If
 
Upvote 0
Try this combo:

Formula in B16 is: =SUMIF(A1:A13,A16,B1:B13)/COUNTIF(A1:A13,A16)
Book1
ABCD
151.2
221.4
331.4
471.2
552.3
641.6
731.5
852.2
961.1
1071.9
1150.9
1241.9
1351.7
14
15
1651.66
Sheet2


P.S. If my formula is too cumbersome, then use Peter's - it offers array of hope. :)
 
Upvote 0
Ooops! I didn't realize there was a difference between median and mean. I suppose mean equates to average. What is the definition of median?
 
Upvote 0
mean=average
median = the middle number in a sorted vector. If there are two middle numbers - i.e. if there are a odd number of numbers in the vector - then the median is the average of the two middle numbers.

Gene, "The Mortgage Man", Klein
 
Upvote 0
Thanks, Gene.

Your next YouTube video should be about all those putz's that don't know the difference between "mean" and "median" :)

P.S. Shouldn't that be:

"If there are two middle numbers - i.e. if there are an even number of numbers in the vector - then the median is the average of the two middle numbers."
 
Upvote 0
Barry - yes of course you are right. It is even. Maybe my next youtube video should be about senile math majors who can't remember the difference between odd and even!

Gene, "The Mortgage Man", Klein
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,236
Members
448,555
Latest member
RobertJones1986

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