How to Find Q1 and Q3: Quartiles Explained with Examples

By Dr. Zubair Khalid, DVM, MS, PhD ·

How to Find Q1 and Q3: Quartiles Explained with Examples

To find Q1 and Q3, sort your data, locate the 25th and 75th percentile positions, and interpolate between the two nearest values if the position lands between data points. Q1 marks the point with 25% of the data below it, and Q3 marks the point with 75% below it [1]. This guide shows how to find Q1 and Q3 by hand, in Python, and in a spreadsheet, using one consistent method throughout.

Quick Answer

  • Sort the data from smallest to largest. Every quartile method assumes sorted values.
  • Find the position of Q1 with $(n + 1) \times 0.25$ and the position of Q3 with $(n + 1) \times 0.75$, where $n$ is the number of data points [1].
  • If the position is a whole number, the quartile is the value at that position.
  • If the position has a decimal, interpolate: take the lower value plus the decimal fraction times the gap to the next value [2].
  • Q2 is the median, and the interquartile range is $IQR = Q3 - Q1$.

Before You Start

You need one column of numeric data and a way to sort it. That is it. Quartiles work on any numeric variable, whether it is exam scores, delivery times, or survey ratings on an interval scale.

Two things cause most confusion.

First, there is no single universal quartile formula. Different software uses different definitions, and they give slightly different answers on the same data [3]. The method in this article is the one taught in many statistics courses and matches the default in several tools, but you should know which method your software uses before comparing results.

Second, quartiles are not the same as quarters of your data. With 12 values, you cannot split them into four groups of exactly 3 and call the boundaries Q1, Q2, and Q3 in every method. The position formula handles the uneven split.

If you want the broader picture of how quartiles fit with percentiles and medians, see what a quartile is.

Step by Step

  1. Sort the data. Arrange all values from smallest to largest. Keep every value, including duplicates.
  1. Count the data points. Call this count $n$.
  1. Find the Q1 position. Use the true index location formula:

$$L_{Q1} = (n + 1) \times 0.25$$

  1. Find the Q3 position.

$$L_{Q3} = (n + 1) \times 0.75$$

  1. Read the value at the position. If $L$ is a whole number, Q1 or Q3 is the value sitting at that position in the sorted list.
  1. Interpolate if $L$ has a decimal. Split $L$ into its integer part and its decimal part. The integer part tells you which value to start from. The decimal part tells you how far to move toward the next value:

$$Q = x_{\text{lower}} + (\text{decimal part}) \times (x_{\text{upper}} - x_{\text{lower}})$$

  1. Find Q2 if you need it. Q2 is the median, so use the same formula with 0.50.
  1. Compute the IQR. Subtract: $IQR = Q3 - Q1$. This is the range that holds the middle 50% of your data.

The same position logic underlies percentile calculations, since Q1 is the 25th percentile and Q3 is the 75th percentile [1].

Worked Example

The dataset is the exam scores of 12 students in a class, sorted ascending.

student_idexam_score
155
262
367
471
574
678
782
885
988
1091
1194
1298

Sorted scores: 55, 62, 67, 71, 74, 78, 82, 85, 88, 91, 94, 98. Here $n = 12$.

Q1 position: $(12 + 1) \times 0.25 = 3.25$

The position is 3.25, so Q1 sits between the 3rd value (67) and the 4th value (71). The decimal part is 0.25.

$$Q1 = 67 + 0.25 \times (71 - 67) = 67 + 1 = 68.0000$$

Q2 position: $(12 + 1) \times 0.50 = 6.50$

Between the 6th value (78) and the 7th value (82).

$$Q2 = 78 + 0.50 \times (82 - 78) = 78 + 2 = 80.0000$$

Q3 position: $(12 + 1) \times 0.75 = 9.75$

Between the 9th value (88) and the 10th value (91).

$$Q3 = 88 + 0.75 \times (91 - 88) = 88 + 2.25 = 90.2500$$

IQR: $90.2500 - 68.0000 = 22.2500$

So Q1 = 68.00, Q2 = 80.00, Q3 = 90.25, and IQR = 22.25. A box plot of these scores built with this method marks Q1 at 68.00, the median at 80.00, and Q3 at 90.25, with the box spanning the IQR of 22.25.

Other Ways to Do It

Python with NumPy. The percentile function takes your data and the percentile you want.

import numpy as np
scores = [55, 62, 67, 71, 74, 78, 82, 85, 88, 91, 94, 98]
q1, q2, q3 = np.percentile(scores, [25, 50, 75], method='weibull')
print(f"q1={q1:.4f}, q2={q2:.4f}, q3={q3:.4f}")

Output:

q1=68.0000, q2=80.0000, q3=90.2500

These match the hand calculation exactly. The method='weibull' option (NumPy 1.22 or later) uses the same $(n+1)$ position rule. NumPy's default method='linear' uses position $1 + (n-1)p$ instead and returns 70.0, 80.0 and 88.75 on this dataset.

Spreadsheets. Excel and Google Sheets both have a QUARTILE family of functions. Both take the quartile number as the second argument, so QUARTILE.EXC(range, 1) returns Q1 and QUARTILE.EXC(range, 3) returns Q3. QUARTILE.EXC uses the same $(n+1)$ position rule as this article and returns 68 and 90.25 here, though it can return an error on very small datasets. QUARTILE.INC and the older QUARTILE use position $1 + (n-1)p$ and return 70 and 88.75 on the same scores.

By hand with an odd count. When $n$ is odd, the position formula often lands on a whole number, which means no interpolation is needed. With 11 data points, the Q3 position is $(11 + 1) \times 0.75 = 9$, so Q3 is simply the 9th value in the sorted list [2].

Troubleshooting

The position lands exactly on a whole number. No interpolation. Take the value at that position directly.

The position is larger than $n$. This should not happen with the $(n+1)$ formula, since $(n+1) \times 0.75$ is always less than $n + 1$. If you see this, you likely used $n \times 0.75$ instead.

Your software gives a different answer. Different packages use different quantile definitions [3]. NumPy, R, Excel, and SPSS do not all agree by default. Pick one method, state it, and stay consistent within a project.

You have duplicate values. Duplicates are fine. They stay in the sorted list and count toward $n$.

You have missing values. Decide how to handle them before you sort. Dropping rows and imputing values give different quartiles.

Common Mistakes

  • Forgetting to sort first. The position formula assumes an ordered list. Running it on unsorted data gives meaningless results. Fix: sort ascending before anything else.
  • Using $n \times 0.25$ instead of $(n + 1) \times 0.25$. Both formulas exist in different textbooks, but mixing them mid-calculation produces wrong positions. Fix: pick one formula and apply it to Q1, Q2, and Q3.
  • Rounding the position before interpolating. If the position is 3.25, do not round to 3 and take the 3rd value. Fix: keep the decimal and use it as the interpolation weight.
  • Interpolating in the wrong direction. The decimal part moves you from the lower value toward the upper value, never backward. Fix: always start at the lower value and add the weighted gap.
  • Calling Q1 the minimum or Q3 the maximum. Q1 and Q3 are interior points, not the ends of the data. Fix: check that Q1 is above your minimum and Q3 is below your maximum.
  • Assuming every tool uses the same definition. Excel, NumPy, and R can return different quartiles for the same numbers [3]. Fix: note the method and the tool when you report results.

Limitations

Quartiles summarize a distribution with three numbers, so they hide the shape of the data. Two datasets can share identical Q1, Q2, and Q3 values while looking completely different, one symmetric and one heavily skewed. A box plot helps, but it still hides gaps, clusters, and multiple peaks.

The bigger limitation is definitional. There is no single agreed quartile formula, and the differences between methods grow as datasets get smaller [4][3]. On a 12-point dataset, two reasonable methods can produce Q1 values that differ by a point or more. That matters when a quartile is a cutoff, such as a pass threshold or a bonus tier. Report which method you used, and if the exact value drives a decision, show the calculation rather than just the number. For related measures like standardized scores, see z-scores and percentiles.

Frequently Asked Questions

How do I find Q1 and Q3 with an even number of data points?

Use the same position formulas. With an even $n$, the positions usually land on a decimal, so you interpolate between the two nearest values. In the 12-score example, Q1 landed at position 3.25 and Q3 at position 9.75, and both required interpolation.

How do you find Q1 and Q3 if the position is a whole number?

Take the value at that position directly. For example, with 11 sorted values, the Q3 position is $(11 + 1) \times 0.75 = 9$, so Q3 is the 9th value with no interpolation needed [2].

What is the difference between Q1, Q2, and Q3?

Q1 is the 25th percentile, Q2 is the 50th percentile and equals the median, and Q3 is the 75th percentile [1]. Together they split the data into four segments, each holding roughly a quarter of the observations.

How do I find the upper and lower quartile in Excel?

Use QUARTILE.EXC or QUARTILE.INC with the quartile number as the second argument. QUARTILE.EXC(A1:A12, 1) and QUARTILE.EXC(A1:A12, 3) match the $(n+1)$ method in this article (68 and 90.25 for the example scores), while QUARTILE.INC uses a different definition (70 and 88.75). QUARTILE.EXC can return an error on very small datasets.

Why does my calculator give a different Q1 than Python?

Different tools implement different quantile definitions, and the results diverge most on small datasets [3]. Neither is wrong in isolation. The fix is to state the method you used and apply it consistently across every calculation in the same analysis. If you need a single summary number for reporting, the midrange is another simple measure, though it is far more sensitive to outliers than the IQR.

References

  1. Quartiles and Box Plots - Data Science Discovery
  2. Seven Examples of finding Q1 and Q3 - Data Science Discovery
  3. Hyndman RJ, Fan Y (1996). Sample Quantiles in Statistical Packages. The American Statistician
  4. Altman DG, Bland JM (1994). Statistics Notes: Quartiles, quintiles, centiles, and other quantiles. BMJ

Further Reading

Related Articles