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.

  1. Sort: 3, 5, 7, 8, 12, 13, 14, 18, 21 (n = 9).
  2. Find the median (Q2): the middle value, 12.
  3. Split the data. With an odd n, leave the median out. Lower half: 3, 5, 7, 8. Upper half: 13, 14, 18, 21.
  4. Q1 is the median of the lower half: (5 + 7) / 2 = 6.
  5. Q3 is the median of the upper half: (14 + 18) / 2 = 16.
  6. 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:

MethodUsed byQ1Q3IQR
Median of halves, excluding the medianMany textbooks, TI-8461610
ExclusiveExcel QUARTILE.EXC, R type 6, SPSS, Minitab61610
InclusiveExcel QUARTILE.INC and QUARTILE, R default, NumPy, Google Sheets7147

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

What the IQR is used for

Common mistakes

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.