Jan has a worksheet that has a list of ages in column A. The ages start at 1 and go through to 100. In column B she has the number of people in each of those ages. Jan needs a formula that will tell her the median age of this group of people.

At first blush you might think that you can use the MEDIAN function to calculate the median. That function works great if you have a simple list of values. For instance, if you were calculating the median for the ages alone, then MEDIAN would work fine. However, in Jan's case she needs the median value for the ages of the people, not for the ages themselves. In other words, the median needs to be weighted by the number of people that are each age. The MEDIAN function cannot handle such a requirement.

It should be pointed out that the median age is going to be different than the average age for a group of people. The average can be calculated most easily by multiplying the age by the number of people that is each age. For instance, in column C you could place a formula such as =A1*B1 and then copy it down the column. Add up the values in columns B and C, and then divide the sum in column C by the sum in column B. The result is the average age for the list of people.

The median age, on the other hand, is the age at which half of the people fall below that age and half above that age. The median age can best be calculated by using an array formula, such as the following:

=MATCH(SUM($B$1:$B$100)/2,SUMIF($A$1:$A$100, "<="&$A$1:$A$100,$B$1:$B$100))

This is a single formula, entered by pressing **Ctrl+Shift+Enter**. The SUMIF function in the formula is used to generate an array of the cumulative number of people who are less than or equal to each age. The SUM portion of the formula gives the midpoint of the total frequency of ages. The MATCH function is then used to look up the midpoint value in the array of cumulative frequencies. This yields an "index number" in the initial array, and since the array consists of the all ages 1 through 100, this index number matches is equivalent to the median age.

*ExcelTips* is your source for cost-effective Microsoft Excel training.
This tip (10595) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365.

**Professional Development Guidance!** Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out *Professional Excel Development* today!

When you are working with sequenced values in a list, you’ll often want to take some action based on the top X or ...

Discover MoreWhen working with data in Excel, you might want to figure out which rows of data represent duplicates of other rows. If ...

Discover MoreIf you have two columns containing dates and weights from those dates, you may want to pick a date associated with a ...

Discover More**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

2020-03-19 23:34:08

Walter Szymanski

2018-03-03 12:37:46

Peter Atherton

Robin

I think that the method is floored. Median takes the middle value of the data, and if there is an even count of the data then the average of the middle two values is the median. Therefore, you should use the median function on all the data.

Say the the ranges 'Ages' has 45 values and the median is 53, you can get the same result with the following formulas where E3 contains the count

=ROUNDUP(E3/2,0) gets the mid value and

=Large(Ages,23) returns 53 the median.

If the range has 46 values then mid data points are 23 & 24

So we get the two values and average them,

=Large(ages,23)+large(Ages,24)/2

With my test data this returned 52.5, just like the median.

(see Figure 1 below)

**Figure 1.**

2018-03-02 10:06:41

Robin

18-34 = 29%

35-54 = 34%

55+ = 38%

So 29% are between 18-34, 34% are between 35-54 and 38% are 55+ - how do I get the median age from these percentages?

2016-08-29 15:27:10

SJ

Your formula is not accepted by EXCEL.

2016-03-24 21:32:10

Eugene

Got a version of Excel that uses the
ribbon interface (Excel 2007 or later)?
**This site is for you!** If you
use an earlier version of Excel, visit
our *ExcelTips* site focusing on the menu interface.

**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

Copyright © 2021 Sharon Parq Associates, Inc.

## Comments