Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help needed with Median If in Excel

I need to return a median of only a certain category on a spread sheet. Example Below

Airline    5
Auto       20
Auto       3
Bike       12
Airline    12
Airline    39

ect.

How can I write a formula to only return a median value of the Airline Categories. Similar to Average if, only for median. I cannot re-arrange the values. Thank you!

like image 326
Alan Avatar asked Jul 19 '11 19:07

Alan


People also ask

What formula is use for the median in Microsoft Excel?

When you are finding median manually, you need to sort the data in an ascending order but in Excel, you can simply use the Median function and select the range and you will find your median. We take the same example as above to find the median of marks obtained by students. So we use =MEDIAN(B2:B12).

What is the conditional median?

To calculate a conditional median based on one or more criteria you can use an array formula that uses the MEDIAN and IF functions together. In the example shown, the formula in F5 is: =MEDIAN(IF(group=E5,data)) where "group" is the named range B5:B14, and "data" is the named range C5:C14.


1 Answers

Assuming your categories are in cells A1:A6 and the corresponding values are in B1:B6, you might try typing the formula =MEDIAN(IF($A$1:$A$6="Airline",$B$1:$B$6,"")) in another cell and then pressing CTRL+SHIFT+ENTER.

Using CTRL+SHIFT+ENTER tells Excel to treat the formula as an "array formula". In this example, that means that the IF statement returns an array of 6 values (one of each of the cells in the range $A$1:$A$6) instead of a single value. The MEDIAN function then returns the median of these values. See http://www.cpearson.com/excel/arrayformulas.aspx for a similar example using AVERAGE instead of MEDIAN.

like image 159
Brian Camire Avatar answered Sep 20 '22 13:09

Brian Camire