How to do a chi-square test in Google Sheets

Test whether two categorical variables are related: build the table of expected counts, get the p-value with CHISQ.TEST, then add the χ² statistic and an effect size.

Updated 2026-09-28·3 min read
Quick answer

Put your observed counts in a table, build a second table of expected counts (row total × column total ÷ grand total), then type =CHISQ.TEST(observed_range, expected_range). The result is the p-value. If it is below 0.05, the two variables are associated.

When to use it

The chi-square test of independence checks whether two categorical variables are related: course format and pass/fail, region and product choice, age group and yes/no answers. Each person must be counted once, in one cell only.

The example data

190 students took the same course online, in a hybrid format or in person. Did the pass rate depend on the format? Enter the counts like this:

ABCD
1PassedFailedTotal
2Online382260
3Hybrid51960
4In person551570
5Total14446190

Row totals in D2:D4 are =SUM(B2:C2) and so on; column totals in B5:D5 are =SUM(B2:B4).

Step 1: the expected counts

If format and outcome were unrelated, each cell would hold row total × column total ÷ grand total. In F2, type:

=$D2*B$5/$D$5

Fill it across to G2 and down to G4. The dollar signs keep the totals fixed while the formula moves.

ExpectedPassedFailed
Online45.4714.53
Hybrid45.4714.53
In person53.0516.95

All expected counts are above 5, so the test is valid.

Step 2: the p-value

=CHISQ.TEST(B2:C4, F2:G4)

Result: p = 0.017. The pass rate depends on the course format (at the 0.05 level). Do not include the totals in the ranges.

Step 3: the χ² statistic and degrees of freedom

=SUMPRODUCT((B2:C4-F2:G4)^2/F2:G4)

Result: χ² = 8.14. The degrees of freedom are (rows − 1) × (columns − 1) = 2 × 1 = 2. You can check: =CHISQ.DIST.RT(8.14, 2) returns the same p-value.

Step 4: the effect size (Cramér's V)

=SQRT(8.14/(190*(MIN(3,2)-1)))

Result: V = 0.21, a small-to-medium association. In the formula, 3 and 2 are the number of rows and columns of the observed table.

Do it in one click with ExplainStats

Select your data, click Run: full results table, assumption checks, a plain-language interpretation and an APA line, free in Google Sheets.

Get ExplainStats free

Step 5: which cells drive the result?

A significant test says there is an association, not where. Standardized residuals, (observed − expected) / SQRT(expected), show which cells are far from what was expected. Values close to or beyond ±2 stand out:

ResidualPassedFailed
Online−1.111.96
Hybrid0.82−1.45
In person0.27−0.47

The largest gap is online students who failed: 22 observed against 14.5 expected. Hybrid students failed less often than expected.

Assumptions and alternatives

  • Use counts, never percentages or means.
  • Each person appears in exactly one cell. For the same people answering twice (before/after), use McNemar's test instead.
  • Expected counts should all be at least 5. For a 2 × 2 table with small counts, use Fisher's exact test (ExplainStats Pro includes it).

How to report it (APA style)

A chi-square test of independence showed a significant association between course format and outcome, χ²(2, N = 190) = 8.14, p = .017, Cramér's V = .21. Online students failed more often than expected.

Frequently asked questions

What does CHISQ.TEST return?

The p-value only. It needs two ranges of the same size: the observed counts and the expected counts. To get the χ² value itself, use a SUMPRODUCT formula or CHISQ.INV.RT(p, df).

What is the minimum expected count for a chi-square test?

The usual rule is that all expected counts should be at least 5. For a 2 × 2 table with small counts, use Fisher's exact test instead.

How do I do a chi-square goodness-of-fit test?

Put the observed counts in one column and the expected counts (total × expected proportion) in another, then =CHISQ.TEST(observed, expected). The degrees of freedom are the number of categories minus 1.

Can I use percentages instead of counts?

No. The chi-square test must be run on raw counts. Percentages give a wrong χ² value and a wrong p-value.

Do it in one click with ExplainStats

Select your data, click Run: full results table, assumption checks, a plain-language interpretation and an APA line, free in Google Sheets.

Get ExplainStats free