How to Find Quartiles and the Interquartile Range

Find Q1, Q2 (the median) and Q3, the interquartile range and 1.5×IQR outlier fences. Why textbooks, Excel and calculators give different quartiles.

Quartiles and the Interquartile Range

Trying to figure out how to find quartiles, you have likely noticed the answer depends on who you ask. A calculator, a spreadsheet and a statistics textbook can each return a different Q1 and Q3 for the same numbers. That is not an error in your data. It is a difference in method. The underlying idea is simple: quartiles split an ordered set into four equal parts, and the interquartile range (IQR) is the distance between the first and third quartiles. There are at least nine named methods for computing quartiles, and the one you use changes your answer. The standard hand-calculation method, where the methods diverge, and which one your spreadsheet is probably using are all covered here.

Quartiles as Medians of Halves

Think of Q1, Q2, Q3 as Medians of Successive Halves

The most reliable way to compute quartiles by hand is to think of Q1, Q2 and Q3 as medians of successive halves of the data. The median is the middle value of an ordered set. That middle value is Q2. To get Q1, take the median of the lower half. To get Q3, take the median of the upper half. The trick, and the source of most confusion, is what counts as the lower and upper half when the set has an even number of values.

For an odd-sized set, the median sits in the exact middle. The lower half is everything below that middle value; the upper half is everything above it. For an even-sized set, there is no single middle value, so the median is the average of the two middle values. The lower half is everything below the lower middle value, and the upper half is everything above the upper middle value. This matches the definition in the OpenStax text, which states that for an even number of data values, the median is the average of the two middle values.

Worked Example with an Odd Number of Values

Take the set 3, 7, 8, 12, 15, 18, 21. There are seven values, so the median is the value at position (7+1)/2 = 4, which is 12. That is Q2. The lower half is 3, 7, 8. Its median is 7, so Q1 is 7. The upper half is 15, 18, 21. Its median is 18, so Q3 is 18. The IQR is 18 minus 7, which is 11. That is the entire calculation. No interpolation, no weighting, no rounding. Just three medians in sequence.

Now try an even-sized set: 4, 9, 11, 14, 17, 20. There are six values, so the median is the average of the two middle values, 11 and 14, which is 12.5. That is Q2. The lower half is 4, 9, 11. Its median is 9, so Q1 is 9. The upper half is 14, 17, 20. Its median is 17, so Q3 is 17. The IQR is 17 minus 9, which is 8. Note that Q1 and Q3 are actual data points in this case, but the median is not. That is normal.

Methods Compared: Tukey, Inclusive, Exclusive

Tukey's Hinge Method

The hand method above is Tukey's hinge method, named after John Tukey, who introduced it in his book Exploratory Data Analysis. Tukey called Q1 and Q3 "hinges" because they are the medians of the lower and upper halves. The hinges equal the type 7 quartiles, the method used by most spreadsheet software, only when the number of values n leaves a remainder of 0 or 1 when divided by 4. For any other n, the hinge and the type 7 quartile differ.

Inclusive vs. Exclusive Methods

The inclusive method, used by Excel's QUARTILE.INC function, is the type 7 method. It includes the median in both halves when computing Q1 and Q3. The exclusive method, used by Excel's QUARTILE.EXC function, is the type 6 method. It excludes the median from both halves. For an even-sized set, both methods give the same result as the hinge method. For an odd-sized set, they do not.

Consider the set 1, 2, 3, 4, 5, 6, 7, 8, 9. The median is 5. The lower half is 1, 2, 3, 4. The upper half is 6, 7, 8, 9. Both the hinge and the inclusive method give Q1 as 2.5 and Q3 as 7.5. The exclusive method gives Q1 as 3 and Q3 as 7. That is a real difference. Which one is correct depends on what you are doing with the answer.

Quartile Methods on One Dataset
MethodAlso CalledQ1 for 1–9Q3 for 1–9IQR
Tukey hingesMedians of halves2.57.55
Inclusive (type 7)QUARTILE.INC, R-72.57.55
Exclusive (type 6)QUARTILE.EXC, R-6374

IQR and the 1.5 Times IQR Rule

Use the IQR to Flag Outliers

Once you have the IQR, use it to flag outliers. Any value below Q1 minus 1.5 times the IQR, or above Q3 plus 1.5 times the IQR, is a suspected outlier. This is the 1.5 times IQR rule, a common rule of thumb for box plots.

For the set 3, 7, 8, 12, 15, 18, 21, the IQR is 11. The lower fence is 7 minus 1.5 times 11, which is 7 minus 16.5, so negative 9.5. The upper fence is 18 plus 16.5, so 34.5. No value is below negative 9.5 or above 34.5, so there are no outliers by this rule. Now add the value 90 to that set. The median becomes 13.5, because the median and quartiles depend on position, not on the size of the largest value.5, so 90 is an outlier. That is the robustness of the median in action: one extreme value changes the mean but not the median, the quartiles, or the IQR.

Five-Number Summary and Box Plots

Build a Box Plot from the Five-Number Summary

The five-number summary is the minimum, Q1, the median, Q3, and the maximum. It is the foundation of a box plot, also called a box-and-whisker plot. The box spans from Q1 to Q3, with a line at the median. The whiskers extend to the most extreme values that are not outliers, and outliers are plotted as individual points. The five-number summary gives you a quick sense of the distribution's center and spread, and it is far more informative than a mean and standard deviation when the data is skewed.

To build a box plot by hand, start with the five-number summary. For the set 3, 7, 8, 12, 15, 18, 21, the summary is 3, 7, 12, 18, 21. Draw the box from 7 to 18, the median line at 12, and the whiskers from 3 to 7 and from 18 to 21. If you add an outlier, the whisker stops at the largest value inside the fence, and the outlier sits beyond it as a separate point. Once you can read a box plot, you can compare two distributions side by side without looking at raw data.

How to Find Quartiles in Practice: Spreadsheets and Calculators

Know Your Spreadsheet Method

When you use a spreadsheet to compute quartiles, know which method it uses. Excel's QUARTILE.INC function uses the inclusive type 7 method. Excel's QUARTILE.EXC function uses the exclusive type 6 method. The median, which is the 50th percentile, is the same under both methods for most sets, but Q1 and Q3 can differ. Google Sheets mirrors Excel's QUARTILE functions.

If you are checking a calculator's output against your own hand calculation, first find out which method the calculator uses. Many online calculators default to the type 7 method because that is what most statistics courses teach. But some use the type 6 method, and a few use Tukey's hinges. The difference is not a rounding error. For an odd-sized set, the difference can be a full data point. If you are comparing your answer to a published answer key, and the key does not state its method, you cannot reliably reproduce its quartiles. That is a fact of the subject, not a flaw in your work.

Common Mistakes and How to Avoid Them

The most common mistake is forgetting to sort the data before finding the median. The median is defined on ordered data. If you skip the sort, you are not finding a median, you are finding the middle of a jumble. The second most common mistake is averaging the two middle values without first sorting. The third is confusing Q1 and Q3. A box plot shows Q1 as the left edge of the box and Q3 as the right edge. If you read a box plot from right to left, you will swap them.

Another failure mode is applying the median to nominal data. The median requires order. If your categories are red, blue, green, there is no median. A related error is using the median to describe a bimodal distribution without noting the two peaks. The median might sit in a gap between the two modes, which makes it a poor summary. The mean has the same problem, but for a different reason. The median is robust to outliers, but it is not robust to multimodality.

The Median versus the Mean and the Mode

The median is the middle value of an ordered set. The mean is the arithmetic average. The mode is the most frequent value. For symmetric data, the median and the mean are close. For skewed data, they diverge. The mean is pulled toward the tail, while the median is not. That is why the median is the better measure of center for income, house prices, and other right-skewed variables.

The mode is a different animal. A set can have no mode, one mode, or several. For bimodal data, the median can sit between the two modes, which is a poor description of the data's shape. The median requires sorting, unlike the mode. The mean requires arithmetic, unlike the median. None of these measures is universally best. The right choice depends on the data and the question.

The Frequency Table and Grouped Data Median

Estimate the Median from Grouped Data

When your data is grouped into a frequency table, you cannot find the exact median because you no longer have the individual values. Instead, estimate the median using interpolation. The formula is the lower boundary of the median class plus the class width times the quantity (half the total frequency minus the cumulative frequency before the median class) divided by the frequency of the median class. That is the standard grouped-data median formula.

This formula assumes the values within each class are evenly distributed, which is rarely true. It is an estimate, not an exact value. The same logic applies to quartiles for grouped data. You can estimate Q1 and Q3 by finding the class that contains the 25th and 75th percentiles, then interpolating. The result is approximate. If you need exact quartiles, you need the raw data.

Ties and Even-Sized Datasets

When a set has an even number of values, the median is the average of the two middle values. That is the convention used by OpenStax, Google Sheets, and most introductory textbooks. Some software, particularly certain quantile methods, returns the lower of the two middle values for the 50th percentile. That is a different convention, and it is rare in introductory statistics.

For quartiles, ties are handled the same way. If the lower half has an even number of values, Q1 is the average of its two middle values. If the upper half has an even number, Q3 is the average of its two middle values. There is no separate tie-breaking rule for quartiles beyond applying the median definition twice.

Which Quartile Method Should You Use?

If you are doing homework and your textbook does not specify, use the Tukey hinge method, because that is what most introductory courses teach. If you are using a spreadsheet, use QUARTILE.INC if you want to match the textbook, or QUARTILE.EXC if you want the method used by some statistical software. The two give different answers for odd-sized sets, so pick one and state it.

If you are checking a calculator's output and the answer does not match, the calculator is probably using a different method. Do not assume the calculator is wrong. Look up its documentation. If it does not state its method, you cannot trust its quartiles. That is not a criticism of the calculator. It is a limitation of the method ambiguity.

Common Questions

What is the difference between Q1 and Q3?

Q1 is the median of the lower half of the data, and Q3 is the median of the upper half. The IQR is Q3 minus Q1.

Why do different calculators give different quartiles?

There are at least nine methods for computing quartiles. Excel's QUARTILE.INC uses type 7, while QUARTILE.EXC uses type 6. Tukey's hinges differ from both for some datasets.

How do you find Q1 and Q3 for an even number of values?

For an even count, the median is the average of the two middle values. Q1 is the median of the lower half, and Q3 is the median of the upper half, excluding the median.

What is the 1.5 times IQR rule?

Any value below Q1 minus 1.5 times IQR or above Q3 plus 1.5 times IQR is considered a suspected outlier. It is a common rule for box plots.

Is the median affected by outliers?

No. The median depends only on the position of values, not their size. A single extreme value changes the mean but leaves the median, quartiles, and IQR unchanged.