CHISQ.TEST and CHITEST in ONLYOFFICE Spreadsheet Editor
Compute a chi-square p-value in ONLYOFFICE from observed and expected counts, with a complete independence table and explicit degrees of freedom.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: for the 2×3 observed and expected tables below, =CHISQ.TEST(H2:J3,H6:J7) has the independent expected p-value 0.135335283237. The legacy CHITEST spelling uses the same inspected calculation method.
Availability and evidence scope
- Introduced: Original introduction release is not established by the sources checked.
- Available: Documented in current unversioned ONLYOFFICE function help, checked October 18, 2026.
- Implementation inspected: Official SDKJS v10.0.0.169, commit
3679e0375a758d7dc59d31337a45461be3525ed8. This establishes a source snapshot, not identical behavior in every installed editor. - Retired or deprecated: Retirement or formal deprecation is not established by these sources. A legacy spelling is not automatically a removed function.
- Testing: Examples are independently calculated or labeled source predictions. No ONLYOFFICE application or calculation-engine execution was performed. No native screenshot or general import/export guarantee is claimed.
Use English names and comma separators as shown; adapt separators outside quoted text if your locale requires semicolons. Keep full precision in calculations and round only the displayed summary.
Syntax: p-value, not the statistic
=CHISQ.TEST(actual_range, expected_range)
=CHITEST(actual_range, expected_range)
The two arguments must have matching dimensions. They contain corresponding observed and expected counts. Expected counts are not category labels or percentages. The result is the right-tail probability associated with the internally calculated Pearson chi-square statistic and the degrees of freedom inferred from the range shape.
The function does not calculate the expected table for you. It also does not inspect sampling design, independence or whether a chi-square approximation is appropriate. Those decisions must be made before interpreting its p-value.
Step-by-step: a 2×3 independence example
Enter this observed table, without row totals or headings inside H2:J3:
| Row | H | I | J | Row total |
|---|---|---|---|---|
| 2 | 20 | 30 | 50 | 100 |
| 3 | 30 | 20 | 50 | 100 |
| Column total | 50 | 50 | 100 | 200 |
For independence, expected count in a cell is its row total times its column total divided by the grand total. For H2 this is 100*50/200=25; for J2 it is 100*100/200=50. Put the expected counts in H6:J7:
| Row | H | I | J |
|---|---|---|---|
| 6 | 25 | 25 | 50 |
| 7 | 25 | 25 | 50 |
Enter =CHISQ.TEST(H2:J3,H6:J7) in B2. The independent expected result is 0.135335283237, about 13.5335% under percentage formatting. Keep the range shapes 2×3: do not add totals to one or both inputs, because totals are not additional independent observations.
Independent calculation of the statistic and probability
For each cell compute (observed−expected)^2/expected. Four cells differ by 5 from an expectation of 25, so each contributes 1. The two cells with observed and expected 50 contribute 0. The sum is statistic 4.
For a two-dimensional r×c table the implementation uses (r−1)*(c−1) degrees of freedom. Here (2−1)*(3−1)=2. The right tail for df=2 is exp(−x/2), so the p-value is exp(−2)=0.135335283237. This separate arithmetic verifies both the statistic and the final tail calculation without running ONLYOFFICE.
A value of 0.1353 is not the probability that the two classifications are independent. It is a tail probability under the specified null reference model. Failure to cross a chosen significance threshold is not proof of independence, and a small p-value would not by itself measure effect size or practical importance.
Advanced case: one-dimensional goodness-of-fit inputs
For the single observed row H2:J2, compare the single expected row H6:J6. The contributions are 1, 1 and 0, so statistic is 2. The implementation uses number of cells minus 1 for a one-row or one-column input, giving df=2. The independent expected p-value is exp(−1)=0.367879441171.
That df is appropriate for a simple three-category goodness-of-fit example with fully specified expected proportions and no parameters fitted from those observations. If you estimate parameters to construct the expected counts, the suitable df can be lower. CHISQ.TEST has no explicit df argument to represent that adjustment. Compute the statistic separately and use a distribution function with the appropriate df, or choose an analysis that matches the fitted model.
Do not reshape a contingency table into a single long row merely to simplify a range reference. The implementation changes its df rule with shape; a 2×3 table uses df=2, while a six-cell vector uses df=5. The values alone do not preserve the intended test when rearranged.
Input assumptions and error handling
Official help recommends each expected count be at least 5. All six expected counts in this example meet that condition. Small expected counts, dependent observations or overlapping categories can invalidate the usual approximation even if the spreadsheet returns a number. Use nonnegative observed counts and strictly positive expected counts, with totals consistent with the model.
The inspected helper rejects mismatched dimensions with its not-available category, conventionally #N/A. An expected numeric zero produces a division-by-zero category. A single-cell pair yields zero df and is rejected. Direct text or Boolean arguments are rejected by the wrapper; within arrays the helper skips some nonnumeric pairs and contains a special first-text-cell branch. Do not rely on those inconsistent coercions to clean a dataset.
Degrees of freedom are determined from the original rectangular dimensions, not from a freshly counted set of retained numeric pairs. Thus blanks or labels inside the ranges can affect the calculation in ways that do not match a properly defined count table. Keep headings outside the input rectangles and validate every cell before interpreting a p-value.
The function does not comprehensively enforce that observed and expected totals match or that every numeric count is statistically meaningful. A returned numeric result is therefore not a data-quality certificate. The source-predicted errors in the checks below have not been observed in the application.
Reproducible checks
These are mathematical expectations or identified implementation predictions, not observed application results. For ranges, use the worked dataset above.
| Formula | Expected result |
|---|---|
=CHISQ.TEST(H2:J3,H6:J7) |
0.1353352832366127 |
=CHITEST(H2:J3,H6:J7) |
0.1353352832366127 |
=CHISQ.TEST(H2:J2,H6:J6) |
0.36787944117144233 |
=CHISQ.TEST(H6:J7,H6:J7) |
1 |
=CHISQ.TEST(H2:J3,H6:I7) |
#N/A |
Compatibility and related functions
The legacy name CHITEST is covered here with the modern name. CHISQ.TEST inherits the CHITEST calculation method in the inspected source. This is calculation-path evidence, not proof that metadata, serialization or every edge case is identical.
Modern dotted names are marked as newer-format functions in the inspected SDKJS metadata. That flag does not establish their introduction date or guarantee support in older file readers. Test a small known-value example when moving a workbook between applications.
Related guides: EXP and LN reproduce the two-degree-of-freedom checks; SUM combines statistic contributions; COUNT helps inspect numeric inputs.
First-party references
- Official CHISQ.TEST help, checked October 18, 2026.
- Pinned SDKJS implementation, including chi-square helpers and argument validation.
- Official CHITEST help, for the related legacy spelling.