Home › Blog › XLSForm Skip Logic, Constraints and Calculations: A Practical Guide for KoboToolbox and ODK
Survey Design

XLSForm Skip Logic, Constraints and Calculations: A Practical Guide for KoboToolbox and ODK

The relevant, constraint and calculation columns explained with copy-ready examples, plus the errors that trip up most KoboToolbox and ODK users.

15 November 2026 · By Karatasi ·4 min read

XLSForm is the standard behind KoboToolbox, ODK and SurveyCTO. You design your form in an Excel workbook, upload it, and the platform turns it into a mobile form. Once you understand a handful of columns, you can build forms far more powerful than any drag-and-drop builder allows.

This guide covers the four columns that control how a form behaves: relevant, constraint, required and calculation. Every example uses the same syntax across all three platforms.

The basics: the survey and choices sheets

An XLSForm has two core sheets. The survey sheet lists your questions, one per row, with type, name and label columns. The choices sheet lists answer options for select questions, linked by a list_name.

survey sheet
type                  name        label
select_one yesno      consent     Do you agree to take part?
integer               age         How old are you?
select_one yesno      has_biz     Do you own a business?
text                  biz_type    What type of business?

choices sheet
list_name   name   label
yesno       yes    Yes
yesno       no     No

You refer to the answer of another question with ${question_name}, which is the key to everything below.

1. Skip logic with the relevant column

The relevant column holds a condition. The question is shown only when the condition is true. To show biz_type only to business owners:

name        relevant
biz_type    ${has_biz} = 'yes'

Note that you compare against the choice name (yes), not the label (Yes), and text values go in single quotes.

Common relevant patterns

GoalExpression
Adults only${age} >= 18
Two conditions${has_biz} = 'yes' and ${age} >= 18
Either condition${status} = 'student' or ${status} = 'unemployed'
Option ticked in a select_multipleselected(${sources}, 'borehole')
Option NOT tickednot(selected(${sources}, 'borehole'))
"Other, specify" follow-upselected(${sources}, 'other')
Question was answered${phone} != ''

Tip: to skip a whole section, put the condition on a begin_group row. Every question inside the group inherits it, so you don't have to repeat the condition on each question.

The consent pattern

Wrap the whole interview in a group that only appears when consent is given:

type           name       relevant
begin_group    main       ${consent} = 'yes'
...            ...
end_group

2. Validation with the constraint column

A constraint rejects answers that break a rule. Inside a constraint, a dot (.) means "this question's answer". Pair it with a constraint_message so the enumerator knows what went wrong.

name       constraint                   constraint_message
age        . >= 15 and . <= 100         Age must be between 15 and 100
hh_size    . >= 1 and . <= 30           Household size must be 1 to 30
children   . <= ${hh_size}              Cannot exceed household size
phone      regex(., '^0[17][0-9]{8}$')  Enter a 10-digit number, e.g. 0712345678

For a select_multiple, count-selected(.) <= 3 limits respondents to three choices, and not(selected(., 'none') and count-selected(.) > 1) stops "None" being ticked alongside other options.

3. The required column

Put yes in the required column for questions that can't be skipped. Add a required_message for a friendlier prompt. Be selective: making every question required frustrates respondents and invites made-up answers. Instead, give sensitive questions explicit "Don't know" and "Prefer not to say" options.

4. Calculations

A row of type calculate computes a value that isn't shown on screen but is saved with the data. Its formula goes in the calculation column.

type        name        calculation
calculate   hh_total    ${adults} + ${children}
calculate   age_years   int((today() - ${dob}) div 365.25)
calculate   income_wk   ${income_month} div 4.33

You can display a calculated value in a later label, for example You said your household has ${hh_total} members. Is that correct?, which is a simple, powerful consistency check.

Common errors (and fixes)

Test before you deploy

Always preview your form (Kobo's Enketo preview or ODK's form preview), then walk through every path: answer "No" to consent, enter boundary values like 15 and 100, and tick "Other". Submit a few test records and download the data to check the export looks the way your analysis needs. Then delete the test records before real collection begins.

Form throwing errors, or too complex to build yourself? We build and fix XLSForms for KoboToolbox, ODK and SurveyCTO, from skip logic and validation to repeat groups, choice filters and multiple languages.

Get help with your XLSForm →

XLSFormKoboToolboxODKSkip logicSurveyCTO

Need your questionnaire built properly?

We design and test data collection tools on Google Forms, Microsoft Forms, KoboToolbox, ODK and SurveyCTO. Free quote within 24 hours.

Get a free quote →