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 or loosely the middle 50 percent of your values cluster together. A small IQR means your data is concentrated; a large IQR means it is spread out. You calculate it by finding two specific positions in your ordered data, then subtracting one from the other.

The IQR is useful because it ignores extreme values at both ends — the very high and very low outliers that can skew your picture of what is typical. If you are comparing salaries, test scores, or sensor readings, the IQR often tells you more about the normal range than the full spread does.

Key Takeaways

  • Sort your data from smallest to largest before you do anything else; unsorted data will give you the wrong answer.
  • Find the median (middle value) first, then find the median of the lower half to get Q1 and the median of the upper half to get Q3.
  • Subtract Q1 from Q3 to get your interquartile range: IQR = Q3 − Q1.
  • The IQR is measured in the same units as your original data, so if your data is in dollars, your IQR is also in dollars.

Step 1: Sort your data from smallest to largest

Arrange every value in your dataset in order, from the lowest to the highest. This is non-negotiable — the quartile positions depend on this order. If your data is already sorted (for example, from a spreadsheet column), you can move to the next step.

Example: If your dataset is 12, 5, 8, 23, 15, you would reorder it as 5, 8, 12, 15, 23.

Step 2: Find the median (Q2)

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 value. If you have an even number of values, the median is the average of the two middle values.

Using the example 5, 8, 12, 15, 23: there are 5 values, so the median is the 3rd value, which is 12. This position is called Q2, though you do not need it to calculate the IQR — it just marks where you split the data in half.

Step 3: Find Q1 (the lower quartile)

Q1 is the median of the lower half of your data — everything below the overall median. Take all values that fall below the median and find their median the same way you found the overall median.

In the example 5, 8, 12, 15, 23, the lower half is 5, 8. The median of these two values is (5 + 8) ÷ 2 = 6.5. So Q1 = 6.5.

If your dataset has an odd number of values and you are unsure whether to include the overall median in the lower half, use this rule: exclude it. The lower half contains only values strictly below the median.

Step 4: Find Q3 (the upper quartile) and subtract

Q3 is the median of the upper half of your data — everything above the overall median. Find the median of all values that fall above the median.

In the example 5, 8, 12, 15, 23, the upper half is 15, 23. The median of these two values is (15 + 23) ÷ 2 = 19. So Q3 = 19.

Now subtract: IQR = Q3 − Q1 = 19 − 6.5 = 12.5. The interquartile range of your dataset is 12.5.

A worked example with an even number of values

Suppose your dataset is 3, 7, 9, 11, 14, 18. There are 6 values (even), so the median is the average of the 3rd and 4th values: (9 + 11) ÷ 2 = 10.

The lower half is 3, 7, 9. The median of these is 7, so Q1 = 7. The upper half is 11, 14, 18. The median of these is 14, so Q3 = 14. Therefore, IQR = 14 − 7 = 7.

Why the IQR matters and when to use it

The IQR is the foundation for detecting outliers. Any value below Q1 − 1.5 × IQR or above Q3 + 1.5 × IQR is often flagged as an outlier in statistical analysis. It is also the basis for box plots, a common way to visualize data spread.

Use the IQR when you want to understand where most of your data sits without being thrown off by a few extreme values. If you are analyzing test scores and one student scored far higher or lower than everyone else, the IQR tells you the range of the typical students, while the full range would be distorted by that one score.

Frequently Asked Questions

What is the difference between IQR and standard deviation?

The IQR measures the spread of the middle 50 percent of your data and ignores outliers. Standard deviation measures how far values typically fall from the average and is affected by every value, including extremes. Use IQR when outliers are present or when you want a straightforward picture of the middle range; use standard deviation when you need a measure that accounts for all variation.

Do I include the median in the upper or lower half?

No. When you split your data at the median, the lower half contains only values below it, and the upper half contains only values above it. The median itself is not included in either half. This rule applies whether your dataset has an odd or even number of values.

Can the IQR be negative?

No. Q3 is always greater than or equal to Q1, so Q3 − Q1 is always zero or positive. An IQR of zero means all values in the middle 50 percent are identical.

What if I have a very small dataset, like only 3 values?

The method works the same way. For 3, 5, 7: the median is 5. The lower half is just 3, so Q1 = 3. The upper half is just 7, so Q3 = 7. IQR = 7 − 3 = 4. With very small datasets, the quartiles may not feel as meaningful, but the calculation is still valid.