The median is the middle value of a data set once you sort the numbers from smallest to largest — the 50th percentile. For an odd count, it's the single central number, so the median of 7 values is the 4th one. For an even count, it's the mean of the two central values. Duplicates stay in the list, and unsorted data is the most common source of wrong answers.
Most people learn the rule in a classroom and then meet it again years later on a spreadsheet, a salary report, or a house-price listing. The rule hasn't changed. What changes is how carefully you handle the boring parts: sorting, counting, and dealing with ties or missing cells. Get those three right and the arithmetic is trivial.
Why Sorting Comes Before Any Counting
Sorting is the step that decides whether your answer is right, and it's where most errors start. Take the list 8, 3, 11, 4, 7. The middle number as written is 11. Sorted, the list is 3, 4, 7, 8, 11, and the median is 7. The raw order of a data set carries no meaning for the median, so the first move is always an ascending or descending sort.
A second trap is a list where sorting is easy to fumble by eye. When you sort 10 values by hand, double-check adjacent pairs — 19 and 91 swap places in a hurry, and so do 2.5 and 2.05. On screen, highlight the whole column before sorting, not just the digits you can see, because a sort that misses one cell moves a value out of the set entirely.
Duplicate values must stay in place. If your list is 2, 2, 2, 3, 9, the median is 2 — not 3. Some people instinctively delete repeats to "clean up" the data, which changes the answer. Cleaning is a separate decision from finding the median, and it has to happen before the count, with a reason you can defend.
Missing values are the silent version of the same problem. A blank cell in a spreadsheet column is not a zero, and treating it as zero drags the median down in small samples. Decide up front whether blanks are excluded (usually correct for a median of observed values) or replaced, and state which one you did.
The Odd-Count Rule: One Number in the Middle
When the set has an odd number of values, the median is the value at position (n + 1) / 2 after sorting. For 9 values that's position 5. For 15 values it's position 8. The formula looks fussy, but its only job is to find the exact center of an odd list, which has no pair to average.
Worked case: daily coffee sales at a small café across 7 days were 41, 38, 52, 47, 44, 39, 50. Sorted: 38, 39, 41, 44, 47, 50, 52. Position (7 + 1) / 2 = 4, so the median is 44 cups. Three days were below that figure and three above, which is exactly what "middle" should mean.
The odd rule scales without extra arithmetic. A list of 101 house prices has its median at position 51 — one number, no averaging, however large the set. What changes with size is the sorting effort, not the rule.
One failure case worth knowing: a set with an even count that you've accidentally miscounted as odd. Nine values and ten values look similar on a page. Count the items twice, or have the spreadsheet do it with a COUNTA formula on the cleaned range, before you apply the position rule.
The Even-Count Rule: Average the Two Central Values
When the set has an even number of values, there is no single middle. The median is the arithmetic mean of the two central values, at positions n/2 and n/2 + 1. For 8 values those are positions 4 and 5. The result may not be a number that appears in your data, and that's fine — the median is a position-based summary, not an observed reading.
Worked case: seven employees earn $34,000, $36,000, $38,000, $41,000, $45,000, $52,000, and one owner earns $240,000. That's 8 values, so the central pair sits at positions 4 and 5: $41,000 and $45,000. The median is $43,000. The mean is $64,571 — dragged upward by the owner's salary. For income data, the U.S. Census Bureau reports medians precisely for this reason; the mean household income it publishes is consistently higher than the median.
A subtle version of the even rule appears when the two central values are identical. In a list of 6 test scores — 61, 64, 70, 70, 83, 90 — the central pair is position 3 and 4, both 70. The average of 70 and 70 is 70, so the median is 70 with no division to do. The rule still applies; the arithmetic just collapses.
The failure case here is forgetting to divide. People spot the two middle numbers and report both, or report the higher one. Write out the addition and division even when it's obvious, and you won't be the person who answers "41 and 45" when asked for a single figure.
A 7-Case Table You Can Check Your Work Against
Different data sets stress different parts of the rule. The table below runs a range of cases through the sort-count-split sequence, including awkward ones people rarely see in textbook examples. Values are chosen so you can verify each by hand.
| Case | Raw data | Sorted data (n) | Central position | Median |
|---|---|---|---|---|
| Odd, already ordered | 2, 5, 9, 12, 14 | 2, 5, 9, 12, 14 (5) | 3rd | 9 |
| Odd, out of order | 8, 3, 11, 4, 7 | 3, 4, 7, 8, 11 (5) | 3rd | 7 |
| Even, clean pair | 10, 20, 30, 40 | 10, 20, 30, 40 (4) | 2nd and 3rd | 25 |
| Even, identical pair | 61, 64, 70, 70, 83, 90 | unchanged (6) | 3rd and 4th | 70 |
| Duplicates | 2, 2, 2, 3, 9 | unchanged (5) | 3rd | 2 |
| Decimals | 1.2, 1.9, 2.05, 2.5, 3.1 | unchanged (5) | 3rd | 2.05 |
| Negative values | −8, −3, 0, 4, 11 | unchanged (5) | 3rd | 0 |
The negative case catches people because the sort order runs from most negative to most positive. −8 comes first, not last. Reading "smallest" as "lowest absolute value" produces the wrong sequence every time.
The decimal case catches a different mistake: assuming 2.5 beats 2.05 because 5 is bigger than 05. Compare digits left to right, or better, let a calculator or spreadsheet sort them. Hand-sorting decimals in a rush is where careless errors concentrate.
Run your own data through the sequence in the table order — sort, count, find the position — and any disagreement with the table points to a specific step rather than "I got a different answer somewhere."
Median, Mean, and Mode Side by Side
The median answers a different question from the mean, and choosing the wrong one is a bigger error than a miscalculation. The mean divides the total by the count and responds to every value. The median sits at the middle position and ignores how extreme the ends are. The mode is the most frequent value and doesn't depend on order at all.
| Measure | Salary set of 8 (from earlier) | Score set of 6 | House prices (5 homes) | What it tells you |
|---|---|---|---|---|
| Mean | $64,571 | 73.0 | $454,000 | Total divided by count |
| Median | $43,000 | 70 | $310,000 | Middle position |
| Mode | none (all different) | 70 | none (all different) | Most frequent value |
The salary set: mean $64,571 against median $43,000 — a gap of $21,571 created by one $240,000 entry. The house prices (say $180,000, $210,000, $310,000, $480,000, $1,090,000) give a mean of $454,000 and a median of $310,000, again because a single high value pulls the total. The score set's mean of 73 comes from (61 + 64 + 70 + 70 + 83 + 90) / 6, while its median of 70 sits below it.
Use the median when the data is skewed, when outliers are genuine readings you can't discard, or when you need a typical value the middle of the group would recognize. Use the mean when every value should count equally — total rainfall, average delivery time across an equal number of packages per driver. Use the mode for categorical data, where "average" is meaningless.
The contrast between mean and median is itself useful information. A large gap signals a lopsided distribution; a small gap tells you the data is roughly balanced around its center, and either measure will do.
How Your Tool Computes It, From Excel to Python
Every mainstream tool has a median function, but the exact name and behavior differ enough to cause trouble. Excel and Google Sheets both use =MEDIAN(range), which ignores text and logical values inside the range. Google Sheets' version of MEDIAN is documented to ignore text cells, which is handy for messy shared sheets but dangerous if you were expecting an error message.
Python's statistics.median() raises StatisticsError on an empty sequence, and returns the central value for odd counts and the arithmetic mean of the middle two for even counts. NumPy's np.median() behaves the same for a flat array but accepts an optional axis argument for 2-D data — a feature Excel doesn't offer without helper formulas.
R takes a different approach entirely. median(x, na.rm = TRUE) is the default call people learn, and without na.rm = TRUE any missing value returns NA. That single argument has ruined more student problem sets than any arithmetic error.
On a TI-84 calculator, the process runs through STAT → Edit, entering the values into L1, then STAT → CALC → 1-Var Stats. The output lists the median under "Med." in the second screen of results. Version differences matter here: older operating systems label the item "Med" and place it below "Sx," while newer ones keep the same position.
The practical advice across all of these: confirm what happens to blank cells before you trust the output. A range that includes one empty cell behaves differently in each tool, and the tool won't flag the difference for you.
Five Mistakes That Produce the Wrong Middle
Most wrong medians come from five specific slips, and each has a quick check.
1: Forgetting to sort. Check: does the position rule point to a value that looks out of place in the raw list? It usually does. 2: Using the mean of the whole set instead of the two central values. Check: for an even count, write the pair down, then average only those two. 3: Deleting duplicates to "tidy" the data. Check: the count should match the original number of observations unless you documented a removal. 4: Counting blanks as zeros. Check: exclude or replace blanks deliberately, and say which. 5: Mishandling negatives or decimals in a hand sort. Check: re-sort the same values in a tool and compare.
Failure case worth knowing in any tool: a range that includes header text. Excel's MEDIAN ignores text, but an automated check that sums the range first may not, and the two results then disagree. Keep header rows out of the selected range.
For a quick sanity check on your answer, confirm that roughly half your data sits below the median and half above. An exact match isn't necessary with odd counts and ties, but a result that sits at the far end of your sorted list is a near-certain error.
Interpretation Limits: What the Median Doesn't Tell You
The median is a single point, and a single point carries no information about spread. Two data sets can share a median of 50 while one clusters tightly between 45 and 55 and the other spreads from 10 to 90. If the spread matters, pair the median with a range, an interquartile range, or a standard deviation.
In small samples the median moves unpredictably. Adding one observation to a 5-value set shifts the median to a different value; adding one to a 500-value set barely moves it. That's one reason large-sample surveys publish medians with confidence intervals rather than a bare figure — the Census Bureau and many national statistics offices do exactly this.
Latency and duration data show the limit sharply. If nine API requests take 20, 22, 24, 25, 27, 31, 33, 41, and 190 milliseconds, the median of 27 ms describes the typical request nicely. But a small fraction of users may hit that 190 ms tail on every request, and the median won't warn them. Pair it with a 95th percentile when tail latency is the risk you're managing.
Finally, the median can't be added or averaged across groups the way a mean can. The median of group A and the median of group B don't combine into a median for the combined group — you need the underlying values. That rule matters in reports where someone tries to average three regional medians into a national figure; the result will be wrong.
FAQ
What is the median of 1 through 100?
The median is 50.5. There are 100 values, so the two central positions are 50 and 51, holding the values 50 and 51; averaging them gives 50.5, a number not in the set. Summing 1 to 100 and dividing by 100 gives the same answer here only because that particular sequence is symmetric — the two measures coincide when the distribution is balanced, which is a special case and not a general rule.
Does the median have to be one of the numbers in the set?
No. Any even-count set whose two central values differ produces a median that doesn't appear in the data. The test scores 61, 64, 70, 70, 83, 90 have a median of 70, which is present, but 41, 42, 46, 48 has a median of 44, which isn't. Looking for an existing value in the data is a reliable sign you've applied the odd-count rule to an even list.
How do I find the median if one value is 0?
Zero sorts first among non-negative numbers, so include it normally in the count. It's a real observation, not a missing value, and the median of 0, 2, 5, 6, 9 is 5. Excluding a legitimate zero shrinks the count and can flip an odd set to an even one, which changes the rule and therefore the answer — a failure you'll see in tidy data with true zeros like "zero minutes of downtime."
What's the difference between median and average?
Average normally means the mean: total divided by count. The median is the middle value after sorting. On a set of 5 salaries — $30k, $32k, $35k, $40k, $300k — the mean is $87.4k and the median is $35k. The mean responds to the outlier; the median doesn't, which is why salary reports and house-price reports lean on the median.
Can I find the median of grouped or binned data?
Yes, with a formula that estimates the value inside the median class. You find the bin where the 50th percentile falls, then interpolate within that bin using the cumulative frequency below it. Spreadsheet software needs a dedicated percentile formula or an add-in for this; a plain MEDIAN on bin midpoints gives a different and usually less accurate answer.
Why does Excel give a different result from my hand calculation?
Usually because the selected range includes a cell you didn't count by hand — a header, a blank, or a value outside the data. Excel's MEDIAN ignores text and empty cells, so an extra header changes nothing, but an extra numeric cell in an adjacent column changes everything. Trace the exact range, then compare the count against your hand tally before trusting either figure.
How many values do I need before the median is meaningful?
There's no fixed threshold, but a 5-value median tells you much less than a 500-value one because each observation moves it more. National statistics offices typically publish medians from samples in the thousands, and any median of a very small sample should be reported with the count beside it. If the sample is under about 20, report the full sorted list rather than a single number.
Is the median in a sorted list always the 50th percentile?
For ungrouped data with no ties crossing the center, yes — the median is the 50th percentile, and spreadsheet percentile formulas reproduce it. With ties, the two concepts can diverge slightly depending on the interpolation method the percentile function uses. When precise percentile boundaries matter, check which interpolation rule your tool or statistical authority specifies, because Excel, R, and Python default to different methods.