← Statistics

Data fundamentals

IQR explained: the middle 50% of your data

When I first learned about the Interquartile Range (IQR), the formula looked simple:

IQR = Q3 − Q1

But the interesting part isn't the calculation. It's what IQR tells us about the data.

What is IQR?

The Interquartile Range measures the spread of the middle 50% of a dataset. To understand it, we first divide the data into four parts:

The distance between Q1 and Q3 is the IQR. So if Q1 is 20 and Q3 is 40:

IQR = 40 − 20 = 20

This means the middle 50% of the observations are spread across 20 units.

Eleven values on a number line with Q1 at 20, the median at 30 and Q3 at 40; the shaded area between Q1 and Q3 is the IQR of 20
Chart 1 Eleven observations with their quartiles. The shaded area between Q1 and Q3 holds the middle 50% of the data.

Why not just use the range?

The range is simply:

Range = Maximum − Minimum

It is easy to calculate, but there is a problem: outliers can completely change it. Imagine these customer order values:

€20 · €25 · €30 · €32 · €35 · €40 · €45 · €500

The €500 order dramatically increases the range. But the IQR focuses on the middle 50% of the data, making it much less sensitive to extreme values.

Bar chart: the range grows from 25 to 480 euros when the 500 euro order is added, while the IQR only grows from 10 to 12.5 euros
Chart 2 The same orders with and without the €500 order. The range jumps from €25 to €480; the IQR barely moves, from €10 to €12.5.

Good to know

There are several ways to calculate quartiles, so Excel, Python or R can return slightly different Q1 and Q3 values for small datasets. The numbers here use the linear-interpolation method (NumPy's default).

That's what makes IQR especially useful for skewed data and datasets with outliers.

IQR and outliers

One of the most common applications of IQR is identifying potential outliers. After calculating the IQR, we can create two boundaries:

Lower bound = Q1 − 1.5 × IQR
Upper bound = Q3 + 1.5 × IQR

Observations outside these boundaries are typically flagged as potential outliers. For example, with Q1 = 20 and Q3 = 40:

IQR = 40 − 20 = 20
Lower bound = 20 − 1.5 × 20 = −10
Upper bound = 40 + 1.5 × 20 = 70

Any observation above €70 or below −€10 would be flagged as a potential outlier. (Order values can't be negative, so in practice only the upper bound matters here.)

Number line with a lower bound at minus 10 and an upper bound at 70; values between them are not flagged, while a value of 88 euros is flagged as a potential outlier
Chart 3 The bounds are 1.5 × IQR beyond Q1 and Q3. Anything outside them, like the €88 order, is flagged as a potential outlier.

Important

An outlier is not automatically an error. It is simply an observation that deserves a closer look.

IQR in a box plot

This is also where IQR becomes visual. In a box plot, the box represents the middle 50% of the data. The bottom (or left side) of the box is Q1, the top (or right side) is Q3, and the distance between them is the IQR. The median sits inside the box, while observations beyond the whiskers may be displayed as potential outliers.

Annotated box plot: the box spans Q1 to Q3 and is the IQR, a line marks the median, whiskers extend to the furthest values within 1.5 times the IQR, and a point beyond is a potential outlier
Chart 4 The anatomy of a box plot. The box is the IQR.

So when looking at a box plot, IQR gives us a quick way to understand how concentrated or spread out the central part of the distribution is.

What IQR tells us

A small IQR means the middle 50% of observations are relatively close together. A large IQR means they are more spread out. For example:

Q1Q3IQR
Dataset A203010
Dataset B206040

Even though both datasets might have the same median, Dataset B has much greater variability in its middle 50%.

Two boxes with the same median: Dataset A is narrow with an IQR of 10, Dataset B is wide with an IQR of 40
Chart 5 Same median, different spread. The wider the box, the larger the IQR.

How to explain IQR to stakeholders

When presenting IQR to stakeholders, I would start with the business question:

How much do our typical values vary?

IQR helps answer this by looking at the middle 50% of the data. This makes it particularly useful when a dataset contains extreme values that could distort the overall picture.

For example, imagine we're analysing customer order values. A few customers might place unusually large orders, but those orders don't necessarily represent typical customer behaviour. Instead of letting these extreme values dominate the analysis, IQR helps us understand where the majority of typical orders are concentrated.

If the middle 50% of orders falls between €20 and €45, we can say that the typical range of order values is relatively concentrated around this interval.

Why does this matter?

Because an average alone can hide the story. Two customer segments could have the same average order value but very different distributions. One might have customers whose orders are consistently similar, while the other might contain a mixture of very small and very large orders.

Two customer segments with the same average order value of 32 euros: Segment A has orders tightly grouped with an IQR of 4 euros, Segment B has orders spread widely with an IQR of 33 euros
Chart 6 Same average, different story (illustrative data). Both segments average €32, but their IQRs are €4 and €33.

IQR gives stakeholders another perspective:

Not just “What is the average?” but “How much variation is there among our typical observations?”

It can also help identify potential outliers that deserve further investigation. But an outlier isn't automatically a mistake. It could represent a VIP customer, a bulk purchase, a special promotion, or simply an unusual but legitimate event.

The takeaway

IQR is more than just a formula. Q1 → 25%, Median → 50%, Q3 → 75%, and IQR = Q3 − Q1. It describes the spread of the middle 50% of the data and provides a simple way to identify potential outliers. For me, that's the real value of IQR: it helps separate the typical pattern from the extreme values.