To calculate the median in Excel, select an empty cell, type =MEDIAN(A2:A10), and press Enter. Replace A2:A10 with the range containing your numbers. You do not need to sort the data first.
This formula works in Excel for Microsoft 365, Excel 2024 and Excel 2021 on Windows and Mac, and Excel for the web. You can also use the basic MEDIAN formula in Excel 2019 and 2016.
The short version
- Basic calculation: Enter
=MEDIAN(A2:A10)in an empty cell and press Enter. - No sorting needed: MEDIAN calculates the middle value without rearranging your data.
- Selected categories: Combine MEDIAN with FILTER to calculate a median for matching rows.
- Exclusions: Use AGGREGATE when you need to ignore error values or hidden rows.
| Method | When to use it | Starting point |
|---|---|---|
| MEDIAN formula | Calculate a range directly | =MEDIAN(A2:A10) |
| AutoSum function picker | Choose MEDIAN on Windows or the web | Formulas > AutoSum > More functions |
| Formula Builder | Choose MEDIAN on Mac | Formulas > AutoSum > More functions |
| Insert Function button | Build the formula on Windows | Insert Function beside the formula bar |
| Table Total Row | Show the median beneath a table column | =MEDIAN(Table1[Amount]) |
| MEDIAN with FILTER | Include rows matching one or more conditions | Filter numeric amounts by category |
| MEDIAN with IF | Use a conditional array formula on desktop | Evaluate matching numeric amounts |
| AGGREGATE | Exclude errors or hidden rows | Function number 12 selects MEDIAN |
Set up your median formula
Select an empty cell where you want the result to appear. For numbers in A2:A10, enter the following formula, replacing that reference with your actual data range, then press Enter:
=MEDIAN(A2:A10)The range inside the parentheses tells Excel which cells to include. Leave the numbers in their existing order, since MEDIAN does not require a sorted list.
Understand your median result
The median is the middle value when the numbers are arranged in order. With an odd number of values, you get the single middle item. With an even number of values, Excel averages the two middle numbers.
For example, the numbers 2, 3, 3, 5, 7 and 10 have a median of 4. The two middle values are 3 and 5, so the result falls between them. Your median therefore does not have to be one of the numbers in the range.
Choose MEDIAN through the function menus
In Excel for Microsoft 365, Excel 2024 or Excel 2021 on Windows, select an empty cell. Open Formulas > AutoSum > More functions, then enter MEDIAN in Search for a function:. Select OK, enter your range in Number1, and select OK again.
In Excel for the web, select an empty cell and open Formulas > AutoSum > More functions. Enter MEDIAN in Search for a function:, then select Next. Enter the range in Number1 and select Insert.
In Excel for Microsoft 365, Excel 2024 or Excel 2021 on Mac, select an empty cell and open Formulas > AutoSum > More functions. In Formula Builder, enter MEDIAN in Search and select Insert Function. Set Number1 to your range, such as A2:A10.
In those Windows versions, you can also start beside the formula bar. Select an empty cell, select Insert Function, enter median in Search for a function, and select Go. Under Select a function, double-click MEDIAN, supply your range as Number1 in Function Arguments, and select OK.
Show the median beneath an Excel table
You can use a table's Total Row in Microsoft 365, Excel 2024 and Excel 2021 on Windows and Mac, and Excel for the web. Select a cell in an existing table, open Table Design > Style Options, and select Total Row. Ribbon grouping varies by platform, so look for Total Row among the table design options.
In the total cell beneath your numeric column, enter the following formula. Replace Table1 with your table name and Amount with the numeric column name:
=MEDIAN(Table1[Amount])You can also open the total-cell dropdown and select More Functions to choose another function. Entering the formula directly lets you specify the table column to include.
Calculate the median for a category
Use MEDIAN with FILTER when you want only rows that match a category. This works in Microsoft 365, Excel 2024 and Excel 2021 on Windows and Mac, and Excel for the web. For categories in A2:A10 and numeric amounts in B2:B10, enter the following formula in an empty cell and press Enter:
=MEDIAN(FILTER(B2:B10,A2:A10="East"))FILTER selects the amounts whose category is East, and MEDIAN calculates their median. Replace the two ranges and the category text with those for your data.
To require both the East category and an amount greater than zero, combine the conditions with multiplication. Enter this version and press Enter:
=MEDIAN(FILTER(B2:B10,(A2:A10="East")*(B2:B10>0)))If no rows match, these formulas return #CALC!. Check the category text and conditions against your data, and correct any mismatch so the formula selects the intended rows.
Use IF for a conditional median on desktop
In dynamic-array-capable Excel for Microsoft 365, Excel 2024 and Excel 2021 on Windows and Mac, you can also combine MEDIAN with IF. Keep numeric amounts in B2:B10, enter this formula in an empty cell, and press Enter:
=MEDIAN(IF(A2:A10="East",B2:B10))The condition selects amounts associated with East for the median calculation. You can use IF statements in Excel to control which values are passed to MEDIAN. Replace the category and ranges with the ones you need.
Fix calculations affected by errors or hidden rows
When you need to exclude error values, use AGGREGATE with function number 12, which selects MEDIAN. AGGREGATE works in Microsoft 365, Excel 2024 and Excel 2021 on Windows and Mac, and Excel for the web. Enter the following formula in an empty cell and press Enter:
=AGGREGATE(12,6,A2:A10)The second argument controls the exclusions. To ignore both hidden rows and error values, use 7 instead of 6, then press Enter:
=AGGREGATE(12,7,A2:A10)For hidden-row exclusion alone, use 5 as the second argument. Enter this version and press Enter:
=AGGREGATE(12,5,A2:A10)Use a vertical range for these formulas. Hiding columns does not provide equivalent behavior, so choose the option based on the rows and errors you want to exclude.
Frequently Asked Questions
Can you calculate a median from ranges that are not next to each other?
You can include separate ranges in one calculation with =MEDIAN(A2:A10,C2:C10). Replace each reference with the range you need, then press Enter.
Can you type numbers directly into MEDIAN?
MEDIAN accepts numbers directly as arguments, without requiring separate worksheet cells. Enter =MEDIAN(2,3,3,5,7,10) and press Enter to calculate from those numbers directly.
Is there a keyboard shortcut for choosing MEDIAN?
Select the result cell and press Shift + F3 to open the function interface. On Windows, choose MEDIAN in Insert Function and supply your range; on Mac, the shortcut opens Formula Builder. It opens the function picker rather than calculating a median directly.
Can quartile or percentile formulas return the median?
Enter =QUARTILE.INC(A2:A10,2) in an empty cell and press Enter to return the second quartile, which is the median. Alternatively, enter =PERCENTILE.INC(A2:A10,0.5) and press Enter to calculate the 50th percentile. Both work in Microsoft 365, Excel 2024 and Excel 2021 on Windows and Mac, and Excel for the web.