IQR in Excel: How to Calculate Interquartile Range
In this article
To find the Interquartile Range (IQR) in Excel, subtract the first quartile (Q1) from the third quartile (Q3) using the formula =QUARTILE.EXC(array, 3) - QUARTILE.EXC(array, 1). The IQR represents the middle 50% of your data set and is a critical measure of statistical dispersion that helps identify the spread of data and detect outliers without being skewed by extreme values.
What You'll Need
- A computer with Microsoft Excel installed (works in Excel 2010 and newer, as well as Excel for the Web).
- A dataset consisting of numerical values organized in a single column or row.
- Basic knowledge of how to select a range of cells in a spreadsheet.
Step-by-Step
- Organize Your Data: Ensure your numerical data is placed in a continuous range. For example, place your numbers in cells A2 through A21. While Excel does not strictly require the data to be sorted from smallest to largest to calculate the IQR, sorting your data via the Data tab > Sort can help you visually verify that the resulting quartiles make sense.
- Identify the First Quartile (Q1): Select an empty cell where you want the Q1 value to appear. Type the formula
=QUARTILE.EXC(A2:A21, 1)and press Enter. TheQUARTILE.EXCfunction excludes the median from the calculation, which is generally preferred for larger datasets in academic and professional statistics. The number "1" tells Excel to find the 25th percentile. - Identify the Third Quartile (Q3): Select another empty cell for the Q3 value. Type the formula
=QUARTILE.EXC(A2:A21, 3)and press Enter. The number "3" tells Excel to find the 75th percentile. - Calculate the IQR: In a third cell, subtract the Q1 cell from the Q3 cell. For example, if Q3 is in cell B2 and Q1 is in cell B1, type
=B2-B1. This result is your Interquartile Range. - Alternative Single-Cell Method: If you do not need to see the individual quartile values, you can combine the steps into one formula:
=QUARTILE.EXC(A2:A21, 3) - QUARTILE.EXC(A2:A21, 1). This performs both calculations and the subtraction in one step. - Verify with INC Function (Optional): Depending on your specific statistical requirements, you may be asked to use
QUARTILE.INC(Inclusive). This version includes the median in the calculation. To do this, simply replace.EXCwith.INCin the formulas above. The difference is usually negligible in large datasets but can be significant in very small samples.
Common Mistakes
One of the most frequent errors is selecting the wrong quartile argument. Using a "2" instead of a "1" or "3" will give you the median, which will result in an incorrect IQR calculation. Another common mistake is including non-numeric data or empty cells that contain hidden characters (like spaces) within the range. Excel may treat these as zeros or ignore them, which can shift the quartile boundaries and lead to an inaccurate range.
Many users also confuse the IQR with the Range. The Range is the difference between the maximum and minimum values (Max - Min), whereas the IQR focuses only on the middle 50%. If your result is an incredibly large number compared to the rest of your data, you may have accidentally calculated the full range instead of the interquartile range.
Finally, mixing QUARTILE.EXC and QUARTILE.INC within the same subtraction formula is a logical error. While the formula will technically run, you are mixing two different mathematical methods for determining quartiles, which invalidates the statistical result. Always stick to one version for both Q1 and Q3.
Tips
To make your spreadsheet more dynamic, use Named Ranges. Instead of typing A2:A21, highlight your data, right-click, and select "Define Name," calling it "DataSet". Your formula then becomes =QUARTILE.EXC(DataSet, 3) - QUARTILE.EXC(DataSet, 1). This makes the formula much easier to read and maintain if you move your data to a different part of the sheet.
If you are using the IQR to find outliers, remember the "1.5 x IQR Rule." Once you have your IQR value, multiply it by 1.5. Any data point that is lower than Q1 - (1.5 * IQR) or higher than Q3 + (1.5 * IQR) is statistically considered an outlier. You can set up these "fences" in adjacent cells to quickly flag anomalies in your data using Conditional Formatting.
For those working with massive datasets, consider using a Table (Ctrl+T). When you convert your data range into a table, any new data added to the bottom of the list is automatically included in the range. If you reference the table column in your QUARTILE formula, the IQR will update in real-time as you add more records.
Troubleshooting
If your formula returns a #NUM! error, it is likely because you used QUARTILE.EXC on a dataset that is too small. The exclusive function requires a minimum number of data points to calculate a quartile outside the range of the data. If you have very few entries, switch to QUARTILE.INC, which is more lenient with small sample sizes.
If you see a #VALUE! error, check your data range for text strings or errors. If a cell in your range contains a word or a formula error (like #DIV/0!), the QUARTILE function will fail. Use the "Find and Replace" tool (Ctrl+H) to remove non-numeric characters or use the AGGREGATE function if you need to ignore error values within the range.
If the result seems mathematically impossible (e.g., a negative number), double-check the order of your subtraction. The formula must always be Q3 minus Q1. If you subtract Q3 from Q1, you will get a negative value because the third quartile is always greater than or equal to the first quartile.
Frequently Asked Questions
What is the difference between QUARTILE.EXC and QUARTILE.INC?
QUARTILE.EXC (Exclusive) excludes the median from the calculation of the quartiles, which is often used in more rigorous statistical analysis. QUARTILE.INC (Inclusive) includes the median. The choice depends on the specific statistical standard you are following, but .EXC is generally more common in academic settings.
Can I find the IQR using a Pivot Table?
Not directly. Pivot Tables can calculate the Sum, Average, and Count, but they do not have a built-in "IQR" or "Quartile" summary calculation. You must use the formulas described above in cells outside the Pivot Table or create a Calculated Field using the QUARTILE functions.
Why is my IQR zero?
An IQR of zero means that at least the middle 50% of your data points are the exact same value. This happens frequently in datasets with low variance or when a single value is heavily repeated (e.g., a survey where most people answered "3").
Does the data need to be sorted for the formula to work?
No, Excel's QUARTILE functions handle the sorting internally. Whether your data is random or sorted, the formula will return the same result. However, sorting is recommended for manual verification.
How do I handle blank cells in my range?
Excel's QUARTILE functions automatically ignore blank cells. However, they do not ignore cells that contain a zero. If a blank cell was filled with a "0" by another process, it will be counted as a data point and will likely pull your Q1 value down, altering the IQR.
Is there a way to calculate IQR in older versions of Excel?
Yes. In versions of Excel prior to 2010, you can use the generic =QUARTILE(array, quart) function. This behaves similarly to QUARTILE.INC. While the newer .EXC and .INC functions provide more precision, the original QUARTILE function is still supported for backward compatibility.