Loading
Excel.Tips.Net ExcelTips (Menu Interface)

Calculating the Median Age of a Group of People

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Calculating the Median Age of a Group of People.

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 (3397) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Calculating the Median Age of a Group of People.

Related Tips:

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!

 

Comments for this tip:

twa14    02 May 2015, 10:17
IF(ISODD(A269),INDEX(A262:B268,(MATCH(SUM(A262:A268)/2,SUMIF(B263:B268,"<="&B263:B268,A262:A268))+1),2),(INDEX(A262:B268,(MATCH(SUM(A262:A268)/2,SUMIF(B262:B268,"<="&B262:B268,A262:A268))+1),2)+INDEX(A262:B268,(MATCH(SUM(A262:A268)/2-1,SUMIF(B262:B268,"<="&B262:B268,A262:A268))+1),2))/2)

I think that the formula above solves the MEDIAN of a frequency distribution problem. Should you get an #N\A sort the frequency's ascending.
twa14    02 May 2015, 06:49
The INDEX\MATCH formula for the median below has a problem (sometimes) with frequency's of "1" in particular if that "1" frequency turns out to be the median. I'm working on it!
twa14    30 Apr 2015, 10:37
(INDEX(A262:B268,(MATCH(SUM(A262:A268)/2,SUMIF(B262:B268,"<="&B262:B268,A262:A268))+1),2)+INDEX(A262:B268,(MATCH(SUM(A262:A268)/2-1,SUMIF(B262:B268,"<="&B262:B268,A262:A268))+1),2))/2

Above should resolve problem outlined in my last post concerning the two numbers to be added, being different. Formula is not fully checked, be careful, good luck. Data in this case in rows A262 to B268

Freq. Aantal Personen
6 1
22 2
8 3
8 4
4 5
3 6
5 10

Median is 2.5

twa14    30 Apr 2015, 08:58
The formula does not work, I have adjusted it as follows.

INDEX(A7:B15,(MATCH(SUM(A7:A15)/2,SUMIF(B7:B15,"<="&B7:B15,A7:A15))+1),2)

This assumes that the frequency is in column A, items in column B. Table goes from A7 to B15 and can of course be adjusted to the data. It seems to work for most cases but if the median is to occur where a summation of the middle two numbers divided by two is necessary it will not give the correct answer if the two numbers to be added are different. Column B probably needs to be in ascending order, I have not fully checked it. Good Luck!

Freq. Item
10 1
5 2
4 3
2 4
10 5
9 6
5 7
6 8
2 9

Median = 5
Tom Jeremiah    17 Dec 2014, 08:38
I FELT THAT THIS WAS VERY VERY USEFUL, I can now conquer excel!
Rawson    19 Nov 2012, 19:50
I have tried this formula, but it does not appear to be correct. If I sum the number of people of either side of the resulting median age, the numbers are vastly different. The result using the above formula gives a median age of 45 years, but when I add the number of persons the median age comes out at 39 years. I under stand the median to be the age at which half of the people fall below that age and half above that age.
 Your comments would be appreciated.
abbas    29 Oct 2011, 21:08
tried using your formula butit does not seem right.the ages I have are interval ages.how do I go about with that.?

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 4+5 (To prevent automated submissions and spam.)
 
          Commenting Terms
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2013)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2013)

Our Products

Premium Newsletters

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2015 Sharon Parq Associates, Inc.