Cross-tabulate Two KoboToolbox Questions
kobo_crosstabCross-tabulate two survey questions to compare how responses to one vary by another, with counts, percentages, means, or sums.
Instructions
Cross two questions to see how answers to one vary with the other — the core of comparative analysis.
Args:
uid (string): the form's asset uid
row_column (string): question forming the rows (field name or label)
col_column (string): question forming the columns
metric: 'count' (default), 'row_pct', 'col_pct', 'mean' or 'sum'
value_column (string): numeric question to average/sum — required for 'mean' and 'sum'
query (string, optional): Mongo-style filter
response_format ('markdown' | 'json')
Returns: the contingency table with row, column and grand totals, and how many submissions were excluded for missing either answer.
Examples:
Use when: "Is crop health worse in some regions?" -> row_column="region", col_column="crop_health"
Use when: "Share of each health status within each region" -> ..., metric="row_pct"
Use when: "Average plot size by region and crop" -> row_column="region", col_column="crop", metric="mean", value_column="plot_size"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | Asset uid of the form (from kobo_list_forms) | |
| query | No | Optional Mongo-style filter applied server-side, e.g. '{"region":"Sud-Ouest"}' or '{"_submission_time":{"$gte":"2026-01-01"}}' | |
| metric | No | count = number of submissions; row_pct/col_pct = percentages; mean/sum = aggregate value_column inside each cell | count |
| col_column | Yes | Question forming the columns of the table | |
| row_column | Yes | Question forming the rows of the table (field name or label) | |
| value_column | No | Numeric question to average or sum. Required when metric is 'mean' or 'sum'. | |
| response_format | No | Output format: 'markdown' for human-readable or 'json' for machine-readable | markdown |