The interquartile range measures the spread of the middle half of your data

The interquartile range (IQR) is the distance between the 25th percentile and the 75th percentile of your dataset. It tells you how tightly the middle 50 percent of your values cluster together. A small IQR means your data points are close to the median; a large IQR means they are spread out. You calculate it by finding two specific values — the first quartile and the third quartile — then subtracting one from the other.

The IQR is useful because it ignores extreme values at both ends of your dataset. If you have one unusually high or low number, the IQR will not change, whereas the full range (highest minus lowest) would jump dramatically. This makes the IQR a more stable way to understand where most of your data actually sits.

Key Takeaways

  • Sort your data from smallest to largest before you do any calculations.
  • Find the median of the lower half of your data to get the first quartile (Q1).
  • Find the median of the upper half of your data to get the third quartile (Q3).
  • Subtract Q1 from Q3 to get the interquartile range: IQR = Q3 − Q1.

Step 1: Sort your data in ascending order

Arrange all your numbers from smallest to largest. This is the foundation for every step that follows. If your data is already in a spreadsheet, use the sort function. If you are working by hand, write the numbers in order on paper or in a text editor.

Example: You have test scores of 85, 92, 78, 95, 88, 76, 90. Sorted, they become: 76, 78, 85, 88, 90, 92, 95.

Step 2: Find the median of your entire dataset

The median is the middle value when your data is sorted. If you have an odd number of values, the median is the single middle number. If you have an even number of values, the median is the average of the two middle numbers.

In the test score example, you have 7 values (odd), so the median is the 4th value: 88. This median divides your data into a lower half and an upper half. The lower half is 76, 78, 85. The upper half is 90, 92, 95. The median itself (88) is not included in either half when you have an odd count.

If you had 8 values instead — say, 76, 78, 85, 88, 90, 92, 95, 98 — the median would be (88 + 90) ÷ 2 = 89. The lower half would be 76, 78, 85, 88, and the upper half would be 90, 92, 95, 98.

Step 3: Calculate Q1 (the first quartile)

Q1 is the median of the lower half of your data. Take only the values below the overall median and find their median using the same rule as before.

In the test score example, the lower half is 76, 78, 85. The median of these three values is 78 (the middle one). So Q1 = 78.

If the lower half had an even number of values, you would average the two middle ones. For instance, if the lower half were 76, 78, 85, 88, then Q1 would be (78 + 85) ÷ 2 = 81.5.

Step 4: Calculate Q3 (the third quartile)

Q3 is the median of the upper half of your data. Take only the values above the overall median and find their median.

In the test score example, the upper half is 90, 92, 95. The median of these three values is 92 (the middle one). So Q3 = 92.

If the upper half had an even number of values, you would average the two middle ones, just as you did for Q1.

Subtract Q1 from Q3 to get the IQR

The interquartile range is straightforward Q3 − Q1. In the test score example: IQR = 92 − 78 = 14.

This means the middle 50 percent of test scores spans a range of 14 points. The lowest score in that middle group is 78, and the highest is 92. Scores below 78 or above 92 are in the outer quartiles.

You can use the IQR to identify outliers. A common rule is that any value below Q1 − (1.5 × IQR) or above Q3 + (1.5 × IQR) is considered an outlier. In this example, 1.5 × 14 = 21, so outliers would be below 78 − 21 = 57 or above 92 + 21 = 113. Since all test scores fall between 76 and 95, there are no outliers in this dataset.

Using a spreadsheet to calculate IQR

Most spreadsheet programs have built-in functions for quartiles. In Microsoft Excel or Google Sheets, use the QUARTILE function. Type =QUARTILE(range, 1) to find Q1 and =QUARTILE(range, 3) to find Q3, where "range" is the cell range containing your data. Then subtract the two results.

In Excel, you can also use =QUARTILE.INC() or =QUARTILE.EXC() depending on whether you want to include or exclude the endpoints of your data. For most purposes, QUARTILE.INC is standard. In Google Sheets, the QUARTILE function works the same way.

If you are using Python, the NumPy library has a percentile function: numpy.percentile(data, 75) − numpy.percentile(data, 25) will give you the IQR directly.

Frequently Asked Questions

What is the difference between range and interquartile range?

Range is the difference between the highest and lowest values in your entire dataset. IQR is the difference between the 75th and 25th percentiles, so it only measures the middle 50 percent. IQR is less affected by extreme outliers, making it more stable for many analyses.

Do I include the median in the lower and upper halves?

If you have an odd number of values, do not include the median itself in either half. If you have an even number of values, there is no single median, so you split the data exactly in half and include all values in one half or the other.

Can the interquartile range be zero?

Yes. If many values in your dataset are identical, Q1 and Q3 can be the same number, making the IQR equal to zero. This means the middle 50 percent of your data has no spread — all those values are the same.

Why is the IQR useful for finding outliers?

The IQR captures where most of your data sits. Values far outside the range Q1 − 1.5(IQR) to Q3 + 1.5(IQR) are unusual enough to warrant a second look. This method is more robust than using standard deviation when your data is skewed or has extreme values.