Median in Excel: How to Calculate the Middle Value
In this article
To work out the median in Excel, use the formula =MEDIAN(range), where "range" refers to the cells containing your numbers. The median is the middle value of a data set when the numbers are ordered from smallest to largest; if there is an even number of values, Excel automatically calculates the average of the two middle numbers. This is particularly useful for analyzing data with extreme outliers, as the median provides a more representative "center" than the average (mean) does.
What You'll Need
- A computer with Microsoft Excel installed (works across Windows, macOS, and Web versions).
- A dataset consisting of numerical values organized in rows or columns.
- Basic familiarity with selecting cells and entering formulas.
Step-by-Step
- Organize Your Data: Ensure your numbers are entered into a continuous range of cells. For example, you might have your data in cells A1 through A20. While the MEDIAN function does not require you to manually sort your data from lowest to highest (Excel does this calculation internally), having your data organized in a single column or row makes it easier to select.
- Select the Output Cell: Click on the empty cell where you want the median result to appear. This is usually a cell directly below or to the right of your data range.
- Start the Formula: Type the equals sign
=. In Excel, every formula must begin with an equals sign to tell the software that you are performing a calculation rather than typing plain text. - Enter the Function: Type
MEDIANfollowed by an open parenthesis(. Your cell should now look like this:=MEDIAN(. - Define the Range: You can define the range of numbers in two ways:
- Click and Drag: While the parenthesis is open, use your mouse to click the first cell of your data (e.g., A1) and drag down to the last cell (e.g., A20). Excel will automatically fill in
A1:A20. - Manual Entry: Type the range manually using a colon to separate the start and end cells, such as
A1:A20.
- Click and Drag: While the parenthesis is open, use your mouse to click the first cell of your data (e.g., A1) and drag down to the last cell (e.g., A20). Excel will automatically fill in
- Close and Execute: Type the closing parenthesis
)and press the Enter key on your keyboard. The cell will now display the median value of the selected range. - Verify the Result: To double-check the accuracy, you can manually sort your data using the Data > Sort menu. Find the middle number in the sorted list; it should match the result provided by the formula.
Common Mistakes
One of the most frequent errors is including non-numeric data within the range. If your range includes text, logical values (TRUE/FALSE), or empty cells, Excel's MEDIAN function ignores them. However, if a cell contains a number formatted as text, Excel will treat it as a non-numeric value and exclude it from the calculation, which can lead to an incorrect median if you believe all your data is being counted.
Another common mistake is confusing the Median with the Mean (Average). The Mean is calculated by adding all numbers and dividing by the count, whereas the Median is the literal middle point. If your data has a few extremely high or low numbers (outliers), the Average will be pulled toward those extremes, but the Median will remain stable. Users often use =AVERAGE() when they actually need =MEDIAN() for a more honest representation of "typical" values.
Some users attempt to manually sort the data and then use a formula to find the middle index. While this works, it is inefficient and prone to error, especially when dealing with an even number of data points where you must manually average the two middle numbers. Using the built-in MEDIAN function eliminates the need for manual sorting and manual averaging.
Tips
If your data is spread across different parts of the spreadsheet, you can calculate the median of non-contiguous ranges. Instead of a single range like A1:A20, you can hold the Ctrl key (Windows) or Command key (Mac) while selecting different cells, or simply separate the ranges with commas in the formula, such as =MEDIAN(A1:A10, C1:C10, E5). This allows you to find the middle value across multiple columns or sheets.
To make your analysis more dynamic, use Named Ranges. Instead of typing A1:A100, you can highlight that range, go to the Name Box (the small box to the left of the formula bar), and type a name like "SalesData". Your formula then becomes =MEDIAN(SalesData). This makes the formula much easier to read and maintain if you move your data to a different part of the sheet.
Combine the MEDIAN function with other tools for deeper insight. For example, comparing the result of =MEDIAN(range) with =AVERAGE(range) can tell you immediately if your data is skewed. If the average is significantly higher than the median, you have high-value outliers pulling the average up.
Troubleshooting
If your formula returns a #NUM! error, it usually means the range you selected contains no numbers. Check to ensure your data isn't accidentally formatted as text. You can check this by looking at the alignment in the cell; by default, numbers align to the right and text aligns to the left. If your numbers are on the left, select the range, click the small warning icon that appears, and select "Convert to Number".
If the result seems incorrect, check for hidden rows or filtered data. The standard =MEDIAN() function includes all cells in the range, even if they are hidden by a filter. If you only want to find the median of the visible cells after applying a filter, you cannot use the MEDIAN function alone. You would need to use a combination of AGGREGATE or a complex SUMPRODUCT formula to ignore hidden rows.
If you see a #VALUE! error, ensure there are no broken references in your formula. This often happens if you have deleted a sheet or a column that the formula was previously pointing to. Re-select your data range to refresh the reference.
Frequently Asked Questions
What happens if there is an even number of values?
When the dataset has an even number of entries, there is no single middle number. In this case, Excel identifies the two middlemost numbers and calculates their average. This result is returned as the median.
Does the MEDIAN function count blank cells?
No, the MEDIAN function ignores empty cells entirely. It only considers cells that contain numerical data. This means blank cells will not shift the middle point of your data set.
Can I find the median of data on different sheets?
Yes. When entering the range part of the formula, you can click on another worksheet tab and select the range there. The formula will look something like =MEDIAN(Sheet2!A1:A50).
Is there a difference between MEDIAN and MODE?
Yes. The median is the middle value of a sorted list. The mode (calculated using =MODE.SNGL()) is the value that appears most frequently in the dataset. They are different measures of central tendency.
How do I find the median if I have specific criteria?
Excel does not have a built-in "MEDIANIF" function. To find a median based on criteria, you must use an array formula combining MEDIAN and IF, such as =MEDIAN(IF(B1:B10="CategoryA", A1:A10)). In older versions of Excel, you must press Ctrl+Shift+Enter to activate this as an array formula.