How to Perform a Chi-Square Test of Independence in Excel
Question details
The user needs to perform a chi-square test of independence on a contingency table but cannot locate the tool in the Analysis ToolPak, seeking an alternative formula or add-in.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Analyzing categorical variables using a contingency table for statistical data analysis.
- Observed behavior
- The standard Analysis ToolPak does not include a dedicated chi-square independence test, requiring the use of manual functions or third-party statistical add-ins.
Ensure your observed data is arranged in a contingency table with calculated row, column, and grand totals. You will need to manually calculate the expected values table before applying the function.
Use the CHISQ.TEST Built-in Function
Calculate the expected counts manually and use Excel's native formula to get the p-value quickly without installing additional add-ins.
Since the Analysis ToolPak does not directly offer a chi-square test, using the built-in CHISQ.TEST formula is the most direct approach. This function calculates the p-value associated with a chi-square test.
Create a new table of the exact same dimensions as your observed data. For each cell, calculate the expected value using the formula: (Corresponding Row Total * Corresponding Column Total) / Grand Total.
Click on an empty cell where you want the final p-value of the chi-square test to be displayed.
Type `=CHISQ.TEST(` into the formula bar or the cell.
Highlight your table of observed values (excluding totals), type a comma, and then highlight your newly calculated table of expected values. Close the parenthesis so the formula looks like `=CHISQ.TEST(actual_range, expected_range)`.
Press Enter to execute the formula. The resulting number is your p-value, determining the independence of your variables.

Install a Third-Party Statistical Add-in
If you perform statistical tests frequently and want to avoid calculating expected tables manually, you can use specialized third-party add-ins.
Perform Chi-Square Tests Seamlessly in WPS Spreadsheet
WPS Spreadsheet fully supports the CHISQ.TEST function alongside a wide range of advanced statistical tools, allowing you to easily process contingency tables and perform data analysis for free.
- 1. Open your data in WPS Spreadsheet: Launch WPS Office and open your spreadsheet containing the observed contingency table.
- 2. Prepare your expected values: Create an expected values table using standard formulas referencing your row, column, and grand totals.
- 3. Apply the function: Click an empty cell and type `=CHISQ.TEST(actual_range, expected_range)`, selecting your observed and expected data tables respectively.
- 4. View your p-value: Press Enter. WPS Spreadsheet will instantly calculate and display the p-value for your test of independence.

Frequently Asked Questions
Why is the Chi-Square Test missing from the Excel Data Analysis ToolPak?
Microsoft Excel's native Data Analysis ToolPak was designed with a specific set of tools and does not include a dedicated Chi-Square test of independence interface. Users must either manually use the CHISQ.TEST formula or install a third-party add-in for automated calculations.
What is the difference between CHISQ.TEST and CHISQ.DIST?
CHISQ.TEST takes your actual and expected data ranges to calculate the p-value directly. CHISQ.DIST (or CHISQ.DIST.RT) calculates the chi-square distribution probabilities based on a manually provided chi-square statistic and degrees of freedom.
How do I calculate the degrees of freedom for a contingency table?
The degrees of freedom for a test of independence are calculated as (Number of Rows - 1) multiplied by (Number of Columns - 1). For a standard 2x2 contingency table, the degrees of freedom is 1.
Does WPS Office support the CHISQ.TEST function?
Yes, WPS Spreadsheet offers full compatibility with Excel statistical functions, including CHISQ.TEST and the legacy CHITEST, ensuring seamless data analysis.




