ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Conditional math
  3. MEDIAN IF in Excel: Find the Median With Conditions

MEDIAN IF in Excel: Find the Median With Conditions

By ExcelReady Team·Updated November 3, 2026·6 min read

The short answer

Excel has no MEDIANIF function, so you put a condition inside MEDIAN. In Microsoft 365 or Excel 2021, use =MEDIAN(FILTER(C2:C8,B2:B8="Sales")). In older Excel, use =MEDIAN(IF(B2:B8="Sales",C2:C8)) and confirm it with Ctrl+Shift+Enter. Both return the middle value of only the rows that match.

Key takeaways

  • There is no MEDIANIF or MEDIANIFS function. Combine MEDIAN with FILTER or IF instead.
  • =MEDIAN(FILTER(C2:C8,B2:B8="Sales")) works in Microsoft 365 and Excel 2021 with a plain Enter.
  • =MEDIAN(IF(B2:B8="Sales",C2:C8)) works in every version, but Excel 2019 and earlier need Ctrl+Shift+Enter.
  • For two conditions, multiply the tests: (B2:B8="Sales")*(C2:C8>1000).
  • Blank cells that match become 0 in both versions, so exclude them with an extra C2:C8<>"" test.
On this page+
  1. Why use a median with conditions?
  2. MEDIAN IF with FILTER (Microsoft 365 and Excel 2021)
  3. MEDIAN IF with IF (every version)
  4. How to find the median with multiple criteria
  5. How to build a median table for every group
  6. Blanks, text and errors in MEDIAN IF
  7. When to use MEDIAN IF instead of AVERAGEIF
  8. Practise it

To get a MEDIAN IF in Excel, you wrap a condition inside MEDIAN, because Excel has no MEDIANIF function. In Microsoft 365 or Excel 2021, =MEDIAN(FILTER(values, condition)) is the simplest way. In older versions, =MEDIAN(IF(condition, values)) does the same job as an array formula. This guide is for anyone who needs a "typical" value for one group, such as the median salary in one department or the median deal size for one team.

Why use a median with conditions?#

The median is the middle value when the numbers are sorted, so one very large or very small number doesn't drag it around. That makes it a better "typical" value than the average for pay, prices, deal sizes and response times. The guide to average vs median explains when each one fits.

The problem is that Excel gives you AVERAGEIF and MAXIFS and MINIFS, but no MEDIANIF. So you build one. All examples use this table in A1:C8:

ABC
1RepTeamDeal
2AnaSales1,200
3BenSupport800
4CaiSales4,500
5DevSales900
6EliSupport1,500
7FaySales2,100
8GusSupport700

MEDIAN IF with FILTER (Microsoft 365 and Excel 2021)#

FILTER returns only the values that meet a condition, and MEDIAN finds the middle of what is left. To get the median Sales deal:

Excel formula
=MEDIAN(FILTER(C2:C8,B2:B8="Sales"))

The result is 1,650. FILTER keeps 1,200, 4,500, 900 and 2,100. Sorted, they are 900, 1,200, 2,100, 4,500. With an even count, the median is the average of the two middle values: (1,200 + 2,100) / 2 = 1,650.

Compare that with the average Sales deal, which is 2,175. The single 4,500 deal pulls the average up, but not the median. For Support, the same formula with "Support" returns 800, the middle of 700, 800 and 1,500.

FILTER needs Microsoft 365 or Excel 2021 or later. The guide to the FILTER function and the FILTER function reference cover its arguments.

MEDIAN IF with IF (every version)#

In older Excel, IF does the filtering. It returns the deal size when the team matches and FALSE when it doesn't, and MEDIAN ignores the FALSE values:

Excel formula
=MEDIAN(IF(B2:B8="Sales",C2:C8))

The result is again 1,650. This is an array formula: it works on a whole range at once.

  • In Microsoft 365 and Excel 2021, press Enter as usual.
  • In Excel 2019 and earlier, press Ctrl+Shift+Enter (Mac: ⌃⇧Return or ⌘⇧Return). Excel shows curly braces { } around the formula. Don't type them yourself.

If you press plain Enter in an old version, the formula may look fine but check only one row, so the result is wrong. The IF function guide explains IF's arguments if the structure is new to you.

How to find the median with multiple criteria#

For two or more conditions, multiply the tests. Each test gives TRUE or FALSE, Excel treats them as 1 and 0, and the product is 1 only when every test is TRUE.

The median Sales deal over 1,000:

Excel formula
=MEDIAN(FILTER(C2:C8,(B2:B8="Sales")*(C2:C8>1000)))

The result is 2,100: the kept values are 1,200, 4,500 and 2,100, and 2,100 is the middle one. The IF version uses the same product as its test:

Excel formula
=MEDIAN(IF((B2:B8="Sales")*(C2:C8>1000),C2:C8))

For OR logic, add the tests instead. (B2:B8="Sales")+(B2:B8="Support") keeps rows from either team. This is the same pattern that AVERAGEIFS with several conditions handles for averages, but written by hand.

How to build a median table for every group#

To show the median for each team, list the teams once and point the formula at each name. In Microsoft 365, type =UNIQUE(B2:B8) in E2. It spills Sales and Support into E2:E3. Then in F2:

Excel formula
=MEDIAN(FILTER($C$2:$C$8,$B$2:$B$8=E2))

Fill it down to F3 (Windows: Ctrl+D; Mac: ⌘D). You get 1,650 for Sales and 800 for Support. The $ signs keep the data ranges fixed while E2 moves to E3.

Blanks, text and errors in MEDIAN IF#

Empty cells are the most common cause of a wrong median. Both FILTER and IF return a blank Deal cell as 0 when its row matches, and MEDIAN counts that 0. Add a test that skips blanks:

Excel formula
=MEDIAN(FILTER(C2:C8,(B2:B8="Sales")*(C2:C8<>"")))

Watch for these too:

ProblemWhat you seeFix
No row matches#CALC! from FILTER=IFERROR(MEDIAN(FILTER(...)),"No data")
Numbers stored as textThey are ignored, so the median is offConvert the column to numbers
An error in the Deal columnThe error passes throughFix the source cell, or add ISNUMBER(C2:C8) as a test
Old Excel, plain EnterA wrong single-row resultConfirm with Ctrl+Shift+Enter
Extra spaces in "Sales "The row isn't matchedClean the column with TRIM

When to use MEDIAN IF instead of AVERAGEIF#

Use the median when a few extreme values would mislead you, and the average when every unit counts equally. Pay bands, house prices and deal sizes usually have a long tail of large values, so the median gives a fairer "typical" number. Totals, budgets and average units per order usually need the average. The article on MEDIAN and MODE shows both side by side on the same data.

A quick check helps you decide. Work out both numbers for the group, here 1,650 for the median and 2,175 for the average. If they are close, either one tells the same story. If the average is much higher than the median, a few large values are pulling it up, and the median is the fairer number to report. Say which one you used in the report, so readers don't compare a median with someone else's average.

Practise it#

A conditional median is two skills joined together: MEDIAN on its own, and FILTER to pick the rows. Practise MEDIAN and MODE in a live spreadsheet, then practise the FILTER function: you type each formula and ExcelReady checks it instantly. Start with the Sales median in the exercise on this page.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Find the median deal size for the Sales team. Click F2 and type a formula that uses MEDIAN and FILTER on C2:C8, then press Enter.

fx
ABCDEFG
1
Rep
Team
Deal
2
Ana
Sales
1200
Sales median
3
Ben
Support
800
4
Cai
Sales
4500
5
Dev
Sales
900
6
Eli
Support
1500
7
Fay
Sales
2100
8
Gus
Support
700
9
10
11

Tip: FILTER keeps the Deal values where the Team is Sales. MEDIAN then finds the middle of those values.

Practise this in a lesson

LessonMEDIAN and MODESee how one outlier skews an average, and describe typical values with MEDIAN and MODE.LessonFILTER: pull matching rows with a formulaReturn every row that meets one or more conditions with FILTER, and show a friendly message when nothing matches.Function guideFILTERReturn every row that matches a condition with Excel's FILTER. Multiple criteria, empty results and #SPILL! explained, with live practice.Function guideIFLearn Excel's IF function with practical examples: flag budgets, label rows and return blanks. Avoid the classic mistakes and practice live.

Frequently asked questions

Is there a MEDIANIF function in Excel?

+

No. Excel has AVERAGEIF, MAXIFS and MINIFS, but no MEDIANIF or MEDIANIFS. You get the same result with =MEDIAN(FILTER(range, condition)) or =MEDIAN(IF(condition, range)).

How do I calculate a median with multiple criteria in Excel?

+

Multiply the tests inside FILTER or IF, for example =MEDIAN(FILTER(C2:C8,(B2:B8="Sales")*(C2:C8>1000))). A row is kept only when every test is TRUE.

Why does my MEDIAN IF formula return the wrong answer?

+

In Excel 2019 and earlier, the IF version must be confirmed with Ctrl+Shift+Enter. Without it, Excel only checks one row. Blank cells can also be counted as 0, which pulls the median down.

Why does MEDIAN with FILTER return #CALC!?

+

FILTER returns #CALC! when no row matches the condition. Wrap the formula in IFERROR, for example =IFERROR(MEDIAN(FILTER(C2:C8,B2:B8="HR")),"No data").

Sources

  • MEDIAN function - Microsoft Support
  • FILTER function - Microsoft Support
  • IF function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 3, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. Why use a median with conditions?
  2. MEDIAN IF with FILTER (Microsoft 365 and Excel 2021)
  3. MEDIAN IF with IF (every version)
  4. How to find the median with multiple criteria
  5. How to build a median table for every group
  6. Blanks, text and errors in MEDIAN IF
  7. When to use MEDIAN IF instead of AVERAGEIF
  8. Practise it

Keep reading

Math· 6 min read

MEDIAN and MODE in Excel: Find the Typical Value

MEDIAN returns the middle value of a range once it is sorted, and MODE returns the value that appears most often. Type =MEDIAN(B2:B8) or =MODE(D2:D11). Use MEDIAN instead of AVERAGE when one extreme value, like a founder's salary, would pull the average away from what is typical. MODE returns #N/A if nothing repeats.

Comparisons· 7 min read

AVERAGE vs MEDIAN: Which Tells the Truth?

Use MEDIAN to describe a typical value when a few very large or very small numbers could skew the result, such as salaries, house prices or order values. Use AVERAGE when the values are fairly even, or when you need a number that multiplies back to the total, as in budgets. When the two differ a lot, report both.

Conditional math· 6 min read

AVERAGEIFS in Excel: Averages With Several Conditions

AVERAGEIFS averages the numbers in one range for the rows that meet every condition you give it. Write =AVERAGEIFS(average_range, criteria_range1, criteria1, ...), for example =AVERAGEIFS(C2:C8,A2:A8,"North",B2:B8,"Swift") for the average delivery days of Swift orders in the North. If no row matches, it returns #DIV/0!.

More on conditional math

  • MINIFS in Excel: Find the Smallest Value That Matches
  • How to Rank by Group in Excel With COUNTIFS
  • Running Count in Excel: Number Each Occurrence With COUNTIF
  • How to Sum by Category in Excel
  • Sum by Date Range or Month in Excel With SUMIFS
  • How to Sum by Day of the Week in Excel
All conditional math articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free