Skip to content

MEDIAN

Returns the middle value of a set of numbers. It is less affected by outliers than the average.

Syntax

=MEDIAN(, [number2], ...)

Statistical

All versions of Excel, including Excel for Microsoft 365 and Excel for the web.

Try it

Edit the formula in B10 or change the inputs. The sheet recalculates as you type.

B10
A
B
C
1
Employee
Salary
2
E01
31,000
3
E02
34,500
4
E03
36,200
5
E04
38,000
6
E05
41,000
7
E06
47,500
8
E07
120,000
9
10
Median salary
38,000

B10 =MEDIAN(B2:B8) returns 38,000

How MEDIAN works

MEDIAN returns the value in the middle once the numbers are sorted. Half the values are below it and half are above. It is the better "typical value" when a few extremes would distort the average: salaries, house prices, response times and order sizes are all lopsided in this way.

How it works

Excel sorts the numbers internally, then:

  • with an odd count, returns the middle value;
  • with an even count, returns the average of the two middle values, so the result may be a number that isn't in the list.

You do not need to sort the data first.

What MEDIAN ignores

In a range or cell reference MEDIAN skips text, blank cells and TRUE/FALSE. Zeros are included. Numbers and logical values typed straight into the formula are counted. If there are no numbers, MEDIAN returns #NUM!. An error value in the data makes the result an error.

Median versus average

Take salaries of 31,000, 34,500, 36,200, 38,000, 41,000, 47,500 and 120,000. The average is about 49,743, higher than six of the seven people earn, because one very high salary pulls it up. The median is 38,000, which is much closer to what most people are paid. When the two figures are far apart, the data is skewed, and quoting only the AVERAGE would be misleading.

Median for one group

MEDIAN has no built-in condition, unlike AVERAGEIF. To find the median for one group, filter the values first:

=MEDIAN(IF(A2:A9="Ops", B2:B9))

In Microsoft 365 this works as typed. In Excel 2019 and earlier, confirm it with Ctrl+Shift+Enter. Another route in Microsoft 365 is =MEDIAN(FILTER(B2:B9, A2:A9="Ops")). The IF version works because MEDIAN ignores the FALSE values that IF returns for non-matching rows.

Related measures

MODE.SNGL returns the most frequent value. PERCENTILE.INC with 0.5 gives the same answer as MEDIAN, and with other fractions finds other cut points. QUARTILE.INC uses 1, 2 or 3 to find the quartiles; quartile 2 is the median.

SUBTOTAL and AGGREGATE can also calculate a median, in AGGREGATE's case (function 12) while ignoring errors or hidden rows.

Arguments

number1
The first number, cell or range, such as B2:B8.
number2, ...optional
More numbers, cells or ranges, up to 255 arguments in all.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Median with an odd count

B10 =MEDIAN(B2:B8)

Result: 38,000

Seven values: the fourth, 38,000, is in the middle.

B10
A
B
C
1
Employee
Salary
2
E01
31,000
3
E02
34,500
4
E03
36,200
5
E04
38,000
6
E05
41,000
7
E06
47,500
8
E07
120,000
9
10
Median salary
38,000

B10 =MEDIAN(B2:B8) returns 38,000

Example 2

Median with an even count

B7 =MEDIAN(B2:B5)

Result: 13.5

Sorted, the values are 9, 12, 15, 20. The middle two are 12 and 15, which average 13.5.

B7
A
B
C
1
Ticket
Minutes to reply
2
T-1
12
3
T-2
15
4
T-3
9
5
T-4
20
6
7
Median reply time
13.5
8

B7 =MEDIAN(B2:B5) returns 13.5

Example 3

Average pulled up by one outlier

B10 =ROUND(AVERAGE(B2:B8),0)

Result: 49,743

The average, 49,743, sits well above the median of 38,000 because of the single 120,000 salary.

B10
A
B
C
1
Employee
Salary
2
E01
31,000
3
E02
34,500
4
E03
36,200
5
E04
38,000
6
E05
41,000
7
E06
47,500
8
E07
120,000
9
10
Average salary (rounded)
49,743

B10 =ROUND(AVERAGE(B2:B8),0) returns 49,743

Example 4

Median for one group

B9 =MEDIAN(IF(A2:A7="Ops",B2:B7))

Result: 34,500

IF passes only the Ops salaries (31,000, 36,200 and 34,500) to MEDIAN, which ignores the FALSE results. The middle value is 34,500. In Excel 2019 and earlier, confirm with Ctrl+Shift+Enter.

B9
A
B
C
1
Dept
Salary
2
Ops
31,000
3
Ops
36,200
4
Sales
41,000
5
Ops
34,500
6
Sales
47,500
7
Sales
38,000
8
9
Median Ops salary
34,500
10

B9 =MEDIAN(IF(A2:A7="Ops",B2:B7)) returns 34,500

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In B9, return the median time to pick an order.

Answer in B9.

B9
A
B
C
D
E
1
Order
Minutes to pick
2
O-1
22
3
O-2
35
4
O-3
18
5
O-4
90
6
O-5
27
7
O-6
31
8
9
Median pick time
10
Average minus median
11

Common mistakes

  • MEDIAN ignores text and blanks but counts zeros. A column where 0 means "missing" pulls the median down.
  • With no numbers in the range, MEDIAN returns #NUM!.
  • There is no MEDIANIF. Use MEDIAN(IF(...)) or MEDIAN(FILTER(...)) for a group, and remember that older versions need Ctrl+Shift+Enter.
  • A median of an even count can be a value that does not appear in your data, such as 13.5.
  • The median ignores how large the extreme values are. If large values matter to the total, the average or the sum may be the right measure.

Questions people ask

What is the difference between mean and median?

The mean (AVERAGE) adds the values and divides by the count. The median is the middle value after sorting. Extreme values move the mean a lot and the median very little.

Does MEDIAN ignore blank cells and zeros?

It ignores blanks and text. Zeros are numbers, so they are included.

How do I calculate a median with a condition?

Use `=MEDIAN(IF(A2:A9="Ops",B2:B9))`, which works as typed in Microsoft 365 and needs Ctrl+Shift+Enter in older versions. `=MEDIAN(FILTER(B2:B9,A2:A9="Ops"))` is another option in Microsoft 365.

Is MEDIAN the same as PERCENTILE at 0.5?

Yes. `=PERCENTILE.INC(B2:B8,0.5)` and `=QUARTILE.INC(B2:B8,2)` give the same answer as `=MEDIAN(B2:B8)`.

Learn MEDIAN in a real sheet.

MEDIAN is taught in Data analysis with formulas, lesson 16: MEDIAN, PERCENTILE and QUARTILE. Each lesson is a short, graded exercise like the one above.