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, and 2013.

**Program Successfully in Excel!** John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out *Excel 2013 Power Programming with VBA* today!

Given a range of cells, you may at some time want to calculate the sum of only the largest values in that range. Here is ...

Discover MoreYou can use the naming capabilities of Excel to name both ranges and formulas. Accessing that named information in a ...

Discover MoreWant to figure out how far it is between two points on the globe? If you know the points by latitude and longitude, you ...

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

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 © 2019 Sharon Parq Associates, Inc.

## Comments