Written by Dackohn; last reviewed November 2026.
To find quartiles, sort the data and find the median, then take the median of the lower half (Q1) and of the upper half (Q3). The IQR is Q3 − Q1. There are several accepted methods: for 3, 5, 7, 8, 12, 13, 14, 18, 21, the textbook method gives Q1 = 6 and Q3 = 16, while Excel’s QUARTILE.INC gives 7 and 14.
The textbook method, step by step
Data: 3, 7, 8, 5, 12, 14, 21, 13, 18.
- Sort: 3, 5, 7, 8, 12, 13, 14, 18, 21 (n = 9).
- Find the median (Q2): the middle value, 12.
- Split the data. With an odd n, leave the median out. Lower half: 3, 5, 7, 8. Upper half: 13, 14, 18, 21.
- Q1 is the median of the lower half: (5 + 7) / 2 = 6.
- Q3 is the median of the upper half: (14 + 18) / 2 = 16.
- IQR = 16 − 6 = 10.
Why calculators disagree
When a quartile falls between two data points, there is no single agreed rule. Here is the same data under each common method:
| Method | Used by | Q1 | Q3 | IQR |
|---|---|---|---|---|
| Median of halves, excluding the median | Many textbooks, TI-84 | 6 | 16 | 10 |
| Exclusive | Excel QUARTILE.EXC, R type 6, SPSS, Minitab | 6 | 16 | 10 |
| Inclusive | Excel QUARTILE.INC and QUARTILE, R default, NumPy, Google Sheets | 7 | 14 | 7 |
None of these is wrong. They are different definitions, and the gap between them shrinks as the sample grows. For coursework, use the method your course teaches.
How the position formulas work
- Inclusive: the position of Q1 is 1 + 0.25 × (n − 1). For n = 9 that is position 3, so Q1 = 7. Q3 is at position 1 + 0.75 × 8 = 7, which is 14.
- Exclusive: the position of Q1 is 0.25 × (n + 1). For n = 9 that is 2.5, halfway between 5 and 7, so Q1 = 6. Q3 is at position 7.5, halfway between 14 and 18, which is 16.
What the IQR is used for
- Spread: the IQR covers the middle 50% of the data, and it is barely affected by extreme values. Report it with the median for skewed data.
- Outliers: values beyond 1.5 × IQR from the quartiles are flagged. See how to detect outliers.
- Box plots: the box runs from Q1 to Q3, with a line at the median.
Common mistakes
- Forgetting to sort the data first.
- Reporting Q1 and Q3 without saying how they were found, which matters in small samples.
- Assuming a different answer is an error. Check which method your software uses.
Try it yourself
Quartile and IQR Calculator →See all the methods side by side, with a box plot. Outlier Calculator →Use the IQR fences to flag unusual values.Frequently asked questions
How do you find Q1 and Q3?
Sort the data and find the median. Q1 is the median of the lower half and Q3 is the median of the upper half. When n is odd, this textbook method leaves out the median.
Why does Excel give a different quartile than my textbook?
Excel's QUARTILE and QUARTILE.INC use an inclusive position formula, while many textbooks take medians of the halves. QUARTILE.EXC often matches the textbook, though not always.
What does the IQR tell you?
It gives the range of the middle 50% of the data. Unlike the full range, it is not affected by extreme values.
Related reading: How to detect outliers · Mean, median and mode · How to calculate variance
Sources & further reading: NIST/SEMATECH e-Handbook of Statistical Methods · OpenStax Introductory Statistics. How we compute & validate: methodology. Written & reviewed by Dackohn; last reviewed August 2026.