Excel IQR Formula: How to Calculate Interquartile Range
In this article
Excel does not have a single built-in function named "IQR," but you can calculate the Interquartile Range easily by combining the QUARTILE.INC or QUARTILE.EXC functions. The IQR is the difference between the third quartile (Q3) and the first quartile (Q1), representing the middle 50% of your data set. This guide walks you through constructing this formula step-by-step, ensuring you select the correct quartile method for your specific statistical needs.
What You'll Need
- A Microsoft Excel spreadsheet with numerical data entered into a column or row.
- An empty cell where you want the IQR result to appear.
- Basic understanding of whether your data represents a sample or a population (to choose between
.INCand.EXCfunctions).
Step-by-Step
- Identify Your Data Range: Click on the cell containing your first data point, hold down the Shift key, and click the last data point to highlight the entire range. Note this range (e.g., A1:A100). Ensure there are no blank cells within this selection unless they are intended to be ignored, as blanks can affect count-based calculations in some contexts.
- Select the Output Cell: Click on an empty cell where you want the final IQR value to display. This keeps your calculation separate from the raw data for clarity.
- Choose the Quartile Function: Decide which quartile definition fits your analysis. Use
QUARTILE.INCif you are working with a sample that includes the minimum and maximum values in the quartile calculation (inclusive). UseQUARTILE.EXCif you are excluding the endpoints, which is often preferred for larger datasets or when following certain statistical conventions. For most general business and academic uses,QUARTILE.INCis the standard default. - Calculate Q1 (First Quartile): In a temporary cell, type
=QUARTILE.INC(A1:A100, 1). ReplaceA1:A100with your actual data range. The second argument,1, specifies the first quartile (25th percentile). Press Enter to see the value. - Calculate Q3 (Third Quartile): In another temporary cell, type
=QUARTILE.INC(A1:A100, 3). The second argument,3, specifies the third quartile (75th percentile). Press Enter to see the value. - Combine into One Formula: To get the IQR directly, subtract Q1 from Q3 in your output cell. Type
=QUARTILE.INC(A1:A100, 3) - QUARTILE.INC(A1:A100, 1). If you chose the exclusive method earlier, replace.INCwith.EXCin both parts of the formula. - Verify the Result: Check that the result is a positive number. The IQR cannot be negative because Q3 is always greater than or equal to Q1 in a sorted dataset. If you see a negative number, double-check that you did not accidentally swap the order of subtraction.
Common Mistakes
The most frequent error is using the wrong quartile function version. Mixing QUARTILE.INC for Q1 and QUARTILE.EXC for Q3 will yield an incorrect IQR because the two methods define quartiles differently based on how they handle the position of the median relative to the data points. Always use the same function variant for both quartiles in the subtraction formula.
Another common issue is including text or empty cells in the range. While Excel's quartile functions generally ignore text and logical values, having them interspersed with numbers can sometimes lead to unexpected results if the range extends beyond the actual data. It is best practice to trim your range to include only the relevant numerical data.
Users often forget to update the range reference if they add new data later. If your dataset grows, remember to expand the range in the formula (e.g., from A1:A100 to A1:A150) or convert your data range into an Excel Table (Ctrl+T) so the references update automatically.
Tips
Use Named Ranges to make your formulas more readable. Instead of typing A1:A100, name the range "SalesData" via the Name Box in the top-left corner. Your formula then becomes =QUARTILE.INC(SalesData, 3) - QUARTILE.INC(SalesData, 1). This makes auditing and updating much easier, especially in complex spreadsheets.
If you need to identify outliers, the IQR is essential. Multiply the IQR by 1.5 to find the outlier threshold. Any data point below Q1 - (1.5 * IQR) or above Q3 + (1.5 * IQR) is typically considered an outlier. You can build these boundaries into adjacent cells to automate outlier detection.
For dynamic arrays in newer versions of Excel, you can use the SORT function combined with INDEX to manually calculate quartiles if you need custom logic, but the built-in QUARTILE functions remain the most efficient and accurate method for standard calculations.
Troubleshooting
If your formula returns a #NUM! error, check that your data range contains at least four numeric values. Quartile calculations require a minimum amount of data to determine the positions of Q1 and Q3 accurately. With fewer than four numbers, Excel cannot compute the quartiles.
If the result is zero, it is likely that all your data points are identical, or the spread of the middle 50% of the data is negligible. Verify your input data to ensure there is variation. If you suspect the formula is referencing the wrong cells, click on the formula bar and visually inspect the highlighted range to confirm it covers the intended data.
If you are getting different results than expected compared to other statistical software, check whether that software uses the inclusive or exclusive method. Many modern statistical packages default to the exclusive method (QUARTILE.EXC equivalent), while older Excel versions defaulted to inclusive. Switching your function from .INC to .EXC may resolve the discrepancy.
Frequently Asked Questions
What is the difference between QUARTILE.INC and QUARTILE.EXC?
QUARTILE.INC calculates quartiles based on the position of the data points including the minimum and maximum values (percentile rank = 0 to 1). QUARTILE.EXC excludes the minimum and maximum values from the quartile calculation (percentile rank = 0 to n+1). .INC is backward-compatible with older Excel versions, while .EXC was introduced in Excel 2010 for better alignment with modern statistical standards.
Can I calculate IQR for multiple columns at once?
Yes. You can drag the formula horizontally across cells. If your formula uses absolute references for the row but relative references for the column (e.g., $A$1:$A$100 vs B1:B100), adjust the references accordingly. Alternatively, use structured references if your data is formatted as an Excel Table.
Does the IQR change if I sort my data?
No. The IQR is a measure of dispersion based on the values themselves, not their order in the spreadsheet. Sorting the data visually helps in identifying outliers, but the mathematical result of the QUARTILE function remains the same regardless of whether the source data is sorted or unsorted.
How do I handle missing data in my range?
Excel's quartile functions automatically ignore empty cells and text entries within the specified range. However, if you have cells containing zeros or other placeholders for missing data, these will be included in the calculation. It is best to leave missing data cells truly blank rather than filling them with arbitrary values like 0 or -999.