How to Get the Median in Excel: MEDIAN Guide
In this article
The median in Excel is calculated with the MEDIAN function. Click an empty cell, type =MEDIAN(A1:A10) using your own range, and press Enter. Excel returns the middle value of that range, which is often a fairer summary than the average when your numbers include a few extreme highs or lows. It works in Excel for Microsoft 365, Excel 2021, 2019, 2016, the free Excel for the web, and the Excel mobile apps, and the formula is identical across all of them.
Below is the full walkthrough, from selecting your data to checking the answer, plus the mistakes that most often produce a wrong median.
What You'll Need
- A spreadsheet with a column or row of numeric data. Text, blank cells and headers are ignored by MEDIAN, but mixing units or formats (numbers stored as text) will silently change the result.
- Any version of Excel: Microsoft 365, Excel 2021, 2019, 2016, Excel for Mac, Excel for the web, or the Excel app on iPhone, iPad and Android.
- An empty cell where the result can go. It can be on the same sheet or a different one.
- Optional: a header row so you can confirm the range you selected is the right one.
Step-by-Step
- Clean the data before you calculate. Scroll through the column you plan to use and check for numbers that Excel has stored as text. They usually sit flush left by default instead of right. You can convert a text number by selecting the cell, opening the warning icon that appears beside it and choosing Convert to Number, or by reformatting the whole column as Number via
Home > Number Format. MEDIAN ignores text entries entirely, so a stray text number quietly disappears from the calculation. - Click an empty cell below the data, to the side of it, or anywhere you want the answer to appear. Leaving at least one blank row between your data and the result keeps things readable.
- Type
=MEDIAN(and do not press Enter yet. The opening parenthesis tells Excel to expect a range. As you type, a tooltip shows the function arguments, which is a quick reminder of the syntax. - Select the range with your mouse. Click the first number and drag to the last, or hold Shift and click the last cell. Excel inserts the range reference into the formula automatically, for example
=MEDIAN(B2:B48). Selecting rather than typing avoids typos in the range. - Close the parenthesis and press Enter. The formula bar shows
=MEDIAN(B2:B48)and the cell shows the median. If the cell displays a decimal that looks wrong, check the number formatting rather than the formula. - Add more ranges if needed. MEDIAN accepts multiple arguments separated by commas, so
=MEDIAN(B2:B48,D2:D48)combines two non-adjacent columns into one calculation. Do not include the header row unless you want it counted as text, which it will be ignored as anyway. - Verify the result with a quick sanity check. Sort a copy of the data from smallest to largest and find the middle value by hand for a small sample. If you have an odd count, the median is the single middle number. If you have an even count, MEDIAN averages the two middle numbers, which is why an even-sized range can return a value that is not actually in your data.
- Fill the formula down or across if you are calculating medians for several groups. Drag the fill handle from the corner of the result cell. Because a plain range reference shifts when copied, anchor the data range with dollar signs, as in
=MEDIAN($B$2:$B$48), if every row should use the same range. If you want a separate median per category, use a full-column reference or an Excel Table instead so each group's range stays correct. - Copy the result as a value if you plan to delete the source data. Select the cell, press Ctrl+C (Cmd+C on Mac), then right-click and choose Paste Special > Values. The number will remain after the original data is cleared.
On Excel for the web and the mobile apps, the formula is typed the same way. On iPhone, iPad and Android, tap the cell, tap the formula entry area and type =MEDIAN(, then tap the first and last cell of the range; mobile Excel inserts the reference for you rather than dragging.
Common Mistakes
- Assuming the median equals the average. AVERAGE adds every value and divides by the count, so one large outlier pulls it up. MEDIAN only looks at position in the sorted list. On the numbers 2, 3, 4, 5, 100, the average is about 22.8 but the median is 4.
- Including totals or subtotals in the range. If your column has a row that sums the rest, MEDIAN counts that total as one more data point and can shift the answer. Exclude summary rows or move them to a separate block.
- Leaving numbers as text. This is the most common cause of a suspiciously low count or an unexpected result. Use
COUNTon the same range and compare it with the number of rows you think you have. - Using MEDIAN where you meant MEDIAN of filtered rows. MEDIAN includes hidden rows from filters. If you only want the visible values, use
SUBTOTALwith the median function number, orAGGREGATE, which can ignore hidden rows and errors. - Confusing MEDIAN with MEDIAN IF. There is no MEDIANIF function in older Excel versions. You would need an array-style formula with IF inside MEDIAN, or the newer
MEDIAN(IF(...))approach entered correctly, or simply filter the data and calculate per group. - Typing a semicolon instead of a comma. Regional settings can change the list separator. If Excel rejects the formula with a comma, try the semicolon your locale uses.
Tips
- Name your range first. Select the data, type a name in the Name Box to the left of the formula bar, then use
=MEDIAN(MyRange). The formula becomes self-documenting and survives inserted rows. - Pair MEDIAN with AVERAGE and MODE side by side. Seeing all three in one row shows at a glance whether the data is skewed.
- Use MEDIAN on an odd-sized sample and you get an actual data value; on an even-sized sample you get a midpoint that may not exist in the data. Mention which you have if you are reporting the number to someone.
- Format the result cell as Number with the decimals you want. MEDIAN inherits nothing from the source cells, so it may display a long decimal or round unexpectedly.
- Wrap MEDIAN in ROUND if you need a clean figure, as in
=ROUND(MEDIAN(B2:B48),0). - For large ranges, click the function name in the formula bar and Excel highlights the cells being used, which is the fastest way to spot a wrong or short range.
Troubleshooting
The cell shows #NAME? Excel does not recognise the function, which almost always means a typo such as MEDAIN or a stray space before the equals sign. Retype it. If the problem persists, confirm you are using an Excel-compatible app rather than a plain text importer.
The result is 0 or blank when you expect a number. The range is probably empty, or every value in it is text. Run COUNT on the same range; if it returns 0, the cells are not real numbers. Reformat the column as Number and re-enter the values.
The result looks too high or too low. Check the range boundaries. It is easy to start one row late and miss a small value or include a header that is actually being read as text. Click the function name and look at the highlighted cells.
The formula copies incorrectly to other rows. You used relative references. Add dollar signs to the range, or convert your data to a Table so references are structured and row-aware.
You get a #VALUE! error. One of the arguments is invalid, often a mismatched parenthesis or an argument that is not a range or number. Rebuild the formula from =MEDIAN( and reselect the range.
Your median ignores rows you wanted included. Hidden or filtered rows are counted by MEDIAN, so the reverse is unlikely; more often a manual selection was cut short. Widen the range to the full column and verify with COUNT.
Frequently Asked Questions
What is the difference between MEDIAN and AVERAGE in Excel?
AVERAGE sums all values and divides by how many there are. MEDIAN returns the middle value of the sorted list, so extreme outliers do not drag it up or down. For salaries, house prices or response times, MEDIAN is usually the more representative number.
How does Excel calculate the median when there is an even number of values?
It takes the two middle values of the sorted list and averages them. In 1, 2, 3, 4 the two middle values are 2 and 3, so MEDIAN returns 2.5, even though 2.5 is not in the data.
Does MEDIAN include blank cells, text or error values?
Blanks, text and logical values in a range reference are ignored. Error values such as #DIV/0! are not ignored: if any error sits inside the range, MEDIAN returns an error too. Remove or fix the errors first.
Can I calculate a median for only some rows, such as one category?
There is no built-in conditional median function in every version. The simplest reliable route is to filter or sort the data by category and run MEDIAN on each group's visible range, or use MEDIAN(IF(...)) entered as an array formula in versions that support it. On Excel 365 and current web Excel, dynamic arrays handle it automatically.
Is MEDIAN available in Google Sheets and Excel for the web?
Yes. Google Sheets uses the same formula name and syntax, =MEDIAN(range), so a sheet moved between the two usually keeps working. Excel for the web supports MEDIAN fully, including on mobile browsers.
Why does my median show more decimal places than my data?
The result cell has its own number format. Select it, go to Home > Number and choose the decimals you want, or use ROUND inside the formula. The underlying value is unchanged by formatting.