There’s no MEDIANIF function, so the median for one group — the typical West-region order, median salary by department — takes MEDIAN + FILTER (Excel 365) or a classic MEDIAN(IF()) array formula.
The example
Order amounts by region. The median West order.
| A | B | |
|---|---|---|
| 1 | Region | Amount |
| 2 | West | $120 |
| 3 | East | $90 |
| 4 | West | $180 |
| 5 | West | $150 |
| 6 | West median: | $150 |
The formula
The median West order (middle of 120, 150, 180):
How it works
Filter to the group, then take the median:
FILTER(B2:B5, A2:A5="West")returns just West’s amounts: {120, 180, 150}.MEDIAN(…)sorts them and returns the middle value —150(with an even count, it averages the two middles).- The median resists outliers far better than the average — one huge order won’t skew it.
- In older Excel, use the array form
=MEDIAN(IF(A2:A5="West", B2:B5))with Ctrl+Shift+Enter.
Build a per-group table: spill a UNIQUE list of regions, then put the MEDIAN(FILTER()) beside each — an instant median-by-group summary.
Try it: interactive demo
Pick a region; see its median order.
Variations
Legacy array formula
Any version — Ctrl+Shift+Enter:
Median with two conditions
Filter on more than one field:
Average by group instead
When you want the mean:
Pitfalls & errors
#CALC! if no rows match. FILTER returns nothing for an unknown group. Add an if_empty: =MEDIAN(FILTER(B:B, A:A=E2, "")) — but note MEDIAN of "" errors, so guard with IFERROR.
Median vs average. Median is the middle value (robust to outliers); average is the mean. They answer different questions — choose deliberately.
FILTER needs Excel 365/2021. Older versions need the MEDIAN(IF()) array formula, entered with Ctrl+Shift+Enter.
Practice workbook
Frequently asked questions
How do I calculate the median for a group in Excel?
Why use median instead of average by group?
How do I find the median with multiple conditions?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class