Descriptive Analysis/ Chi-Square Test
Cross-Tabulation

How to Perform a Chi-Square Test

How to compare two categorical variables in a two-way frequency table — and what the chi-square test tells you about the relationship between them.

7 min read Descriptive Analysis Beginner to Intermediate

Survey data is full of questions that look simple on the surface: does programme participation vary by gender? Does satisfaction differ between districts? Do trained and untrained groups respond differently? These are questions about whether two categorical variables are related — and the chi-square test, run through a cross-tabulation, is the standard way to answer them.

01What is the chi-square test?

The chi-square test is a way of asking whether two categorical variables are related to each other, or whether their distributions are independent. Two variables are independent when knowing someone's value on one tells you nothing about their value on the other. They are related when the distribution of one shifts depending on the value of the other.

The test works by comparing what you actually observed in the data with what you would expect to see if the two variables were completely unrelated. Those expected values are calculated from the row and column totals alone — they represent the counts that would fill each cell if the variables had no connection at all. If the observed and expected counts are close, the data is consistent with independence. If they diverge substantially, there is evidence of a relationship.

The chi-square statistic summarises the total amount of that divergence across all cells in the table. The larger it is, the further the data is from what independence would predict. The p-value then converts that statistic into a probability: the chance of seeing a difference at least this large if the variables were truly unrelated in the wider population. A small p-value means that chance alone is an unlikely explanation for the pattern you observed.

The chi-square test does not describe what the relationship is, how strong it is, or which direction it runs. It only answers whether the evidence is strong enough to conclude that a relationship exists at all. Understanding the nature and size of the relationship requires reading the cross-tabulation table alongside the test result.

02What is cross-tabulation, and how does it relate?

A cross-tabulation — also called a contingency table or crosstab — is the format in which the chi-square test is presented and read. It arranges the two variables in a grid: the categories of one variable form the rows, and the categories of the other form the columns. Each cell in the grid shows how many respondents fall into that particular combination of values.

The table makes the pattern visible in a way the test statistic alone cannot. Where a chi-square value just gives you a number, the cross-tabulation shows you where observed and expected counts diverge — which groups are over-represented, which are under-represented, and what the actual distributions look like across each category. The two always go together: the table shows you what is happening; the test tells you whether what you see is likely to reflect a real pattern or could plausibly be noise from sampling.

For example, if you cross-tabulate programme participation (yes / no) by gender (male / female), the table shows you the participation rate for each gender side by side. The chi-square test then tells you whether the difference between those rates is large enough to be taken seriously given your sample size.

03What is Cramér's V?

The chi-square statistic has one important limitation: it grows with sample size. A relationship of exactly the same strength will produce a larger chi-square value in a dataset of 5,000 respondents than in one of 200. This means the statistic alone cannot tell you how strong the relationship is — only that it is detectable given the sample you have.

Cramér's V solves this by converting the chi-square statistic into a standardised measure of association that is independent of sample size. It ranges from 0 to 1, where 0 means the two variables are completely unrelated and 1 means knowing one variable perfectly predicts the other.

As a practical guide for interpreting Cramér's V in social and evaluation research:

These thresholds are not rigid rules — what counts as meaningful depends on the context. Use them as a starting point for interpretation, not as a mechanical cutoff.

Always report Cramér's V alongside the p-value. A statistically significant result (p < 0.05) tells you the relationship is unlikely to be zero. Cramér's V tells you how large it is. In a sample of 2,000, even a V of 0.04 will produce a significant p-value — but a V that small is almost certainly not worth reporting as a substantive finding.

04A worked example

Suppose a baseline survey of 200 households records whether each household is enrolled in a nutrition programme (yes or no) and the respondent's education level (primary or secondary). The cross-tabulation looks like this:

Enrolled (Yes) Not enrolled (No) Row total
Primary education 30 70 100
Secondary education 60 40 100
Column total 90 110 200

Step 1: Calculate expected counts

If education and enrolment were completely unrelated, each cell would contain a count proportional to its row and column totals. The formula for any cell is:

Expected = (Row total × Column total) ÷ Grand total

Applying this to each cell:

These expected counts represent what the table would look like if education had no bearing on enrolment. Compare them with the observed counts: primary-educated households are enrolled at 30%, while secondary-educated households are enrolled at 60%. The pattern clearly diverges from what independence would produce.

Step 2: Calculate the chi-square statistic

The chi-square statistic sums the squared difference between observed and expected counts, divided by the expected count, across all cells:

χ² = Σ (Observed − Expected)² ÷ Expected

χ² = 5.00 + 4.09 + 5.00 + 4.09 = 18.18

With 1 degree of freedom ([rows − 1] × [columns − 1] = 1 × 1 = 1), a chi-square of 18.18 gives a p-value well below 0.001. The result is highly statistically significant — the pattern is very unlikely to have arisen by chance.

Step 3: Calculate Cramér's V

To understand the strength of the relationship, we calculate Cramér's V. For a 2 × 2 table, the formula simplifies to:

V = √(χ² ÷ n) = √(18.18 ÷ 200) = √0.0909 = 0.30

A Cramér's V of 0.30 indicates a strong association. Secondary-educated households are substantially more likely to be enrolled — and the size of that difference is large enough to be practically meaningful, not just statistically detectable.

You never need to do this by hand. AnalyZ Solutions computes the chi-square statistic, p-value, and Cramér's V automatically when you run Cross-Tabulate. The worked example above is here to make the logic transparent, so you can interpret the output with confidence.

05How to do it in AnalyZ Solutions

Open Descriptive Analysis and select Cross-Tabulate.

  1. Select the variable on the side (rows). Choose the variable whose distribution you want to explain or describe. Its distinct values will appear as row labels down the left side of the table.
  2. Layout preview
    As soon as you select a variable, a table layout preview appears below the Generate button. It shows a skeleton of the output — the column variable as header, the row variable down the side — so you can confirm the structure is correct before running. The preview is replaced by the real table when you click Generate. If you change your variable selection after generating, the preview reappears automatically to reflect the new selection.
  3. Select the variable at the top (columns). Choose the grouping variable — the one you want to compare across. Its distinct values will appear as column headers across the top.
  4. Choose the percentage type. Select Row %, Column %, Total %, or Counts only. Column % is the most common choice in evaluation reports.
  5. Include missing values (Optional). Tick Include missing values to add a Missing category for either variable, so non-response is visible rather than silently excluded.
  6. Apply a subsample filter (Optional). Apply filter to restrict the analysis to a subset of rows.
  7. Click Generate. The table and test statistics appear immediately.

Running a chi-square test with cross-tabulation in AnalyZ Solutions.

An alternative approach
The chi-square test is also available in Inferential Analysis → Compare Percentages → Chi-square. The difference is one of emphasis. Cross-Tabulate in Descriptive Analysis centres the contingency table — the counts and percentages are the primary output, with chi-square and Cramér's V as supporting statistics. The Inferential route centres the test result itself — the χ² statistic, degrees of freedom, p-value, significance rating, and a plain-English interpretation — with the table as supporting context. Use Descriptive when you want to present and read the distribution; use Inferential when the test result is the finding you are reporting.

06How to read the output

The output has two parts: the cross-tabulation table and the test statistics below it.

Reading the table

The table shows the values of one variable as row labels down the side, and the values of the other as column headers across the top. Each cell shows a count and, depending on the percentage option you chose, a percentage. The last row and column are marginal totals.

The most useful percentage direction depends on which variable is doing the grouping:

Reading the test statistics

Three statistics appear below the table. Read all three together for a complete picture of the result.

Small expected cell counts. The chi-square test produces unreliable results when any expected cell count falls below 5. A warning appears when this happens. The usual fix is to combine small categories using Recode Variable in Data Management, then re-run.

07Common mistakes to watch for

When to use the chi-square test and cross-tabulation
  • Both variables are categorical — they group respondents into named categories.
  • You want to ask whether the distribution of one variable differs across the categories of another.
  • Each respondent or record appears only once in the data (independent observations).
  • Expected cell counts are all 5 or above (or can be made so by combining categories).
Not appropriate when: either variable is continuous, the same respondent appears in multiple rows, or you want to compare group means rather than distributions.

08Export and next steps

Results can be exported as CSV, Excel, or Word. The Word export includes the table, the chi-square statistics, and a plain-English interpretation of the result. Use Add to AnalyZense to include the result in a project, or Add to Canvas to place it on the Data Canvas.

After cross-tabulation, a natural next step is to explore whether the relationship holds within subgroups. Re-run the crosstab with a subsample filter to check, for example, whether the education-by-enrolment pattern looks the same in urban and rural areas, or across different programme types.

Frequently Asked Questions
What is the chi-square test actually measuring?
It measures how different your observed cell counts are from the counts you would expect if the two variables were completely unrelated. The expected count for each cell is calculated from the row and column totals. If observed and expected counts are similar across all cells, the chi-square statistic is small and there is no evidence of a relationship. If they diverge substantially in one or more cells, the statistic is large and the p-value will be small.
My p-value is below 0.05 but Cramér’s V is very small. Which should I report?
Report both, and let Cramér’s V guide how you describe the finding. A statistically significant result with a small V (say, 0.05 or 0.08) means the relationship exists but is negligible in practical terms — it would not change any decision or interpretation. You might note it as statistically significant but practically unimportant. A significant result with a V of 0.25 or higher is worth describing as a substantive finding.
What does it mean if the p-value is exactly 0.000?
A p-value displayed as 0.000 means the true p-value is less than 0.001 — it is very small but not literally zero. Report it as p < 0.001 in any written output, not as p = 0.000.
Which variable should go on the rows and which on the columns?
Convention places the independent variable (the grouping factor) in the columns and the dependent variable (what you want to explain) in the rows. With column percentages, this lets you compare the row variable’s distribution across each column group by reading down each column. The placement does not affect the chi-square statistic or p-value — only the percentage direction changes.
My variable is not appearing in the variable picker. Why?
Cross-Tabulate only shows categorical variables. A numeric variable with more than 10 unique values is automatically classified as continuous and will not appear. To use it, either recode it into groups (such as age groups) in Data Management, or change its variable type to categorical in Data Management or the Column Inspector in Data View.
Can I control for a third variable in the cross-tabulation?
The Cross-Tabulate function produces a two-variable table. To examine a relationship within a subgroup — effectively controlling for a third variable — use the Subsample Filter to restrict the rows to a specific group and re-run. For example, to check whether the gender-by-participation relationship holds in both urban and rural areas, run the crosstab twice with a subsample filter set first to urban, then to rural.
I got a warning about small expected cell counts. What should I do?
Combine the small categories with a related category using Recode Variable in Data Management, then re-run. For example, if "Other" has only 3 responses, merge it with the nearest substantive category. As a rule of thumb, all expected cell counts should be 5 or above for the chi-square test to be reliable.
Can chi-square tell me which specific cells are driving the result?
Not directly — the chi-square statistic is a single summary across all cells. To identify which cells diverge most from expected counts, read the cross-tabulation table carefully and compare the observed percentages with what equal distribution across groups would produce. Cells where the observed percentage is substantially higher or lower than the marginal total percentage are contributing most to the result.

Ready to test relationships between two variables in your data?

Open Descriptive Analysis in AnalyZ Solutions. Free to sign up, free to analyze.

Get started
Related Guides