SurveyLoopr
Tips & Tricks
12 min read

End a Survey Early in XLSForm: Consent and Screening

Mehrab Ali
Mehrab AliPublished November 23, 2026

To end a survey early in XLSForm, put every question after the consent or screening question inside one group, and write the condition for carrying on, such as ${consent} = '1', in that group's relevant column. XLSForm has no "end survey" or "skip to end" command, so this one group does the job of a skip rule on every row. Every example below compiles with pyxform and ODK Validate, the check ODK Central runs when you upload a form.

Download example form (.xlsx)All six examples in one XLSForm, one group each. Tested with pyxform and ODK Validate; free to reuse under CC BY 4.0.Download

Ask for consent, then open a group on the next row and close it on the last row of the form. The group's relevant condition decides whether anything inside is asked:

typenamelabelrequiredrelevant
select_one yes_noconsentDo you agree to take part in this interview?yes
begin groupinterviewHousehold interview${consent} = '1'
integerhh_sizeHow many people live in this household?yes
select_one yes_nohas_latrineDoes the household have a latrine?yes
end groupinterview
noteend_refusedThe respondent did not agree. Thank them and save the form.${consent} = '0'
surveychoicessettings
list_namenamelabel
yes_no1Yes
yes_no0No
surveychoicessettings

When the answer is No, the group is skipped and the next screen is the closing note, then the end of the form. The enumerator saves and sends it like any other interview, so the refusal is counted.

Three things make this work:

  • The consent question sits outside the group. A group cannot depend on a question inside itself.
  • Required questions in a skipped group do not block the form. required only applies to questions that are shown.
  • Skipped answers are blank in the submission. If the enumerator fills in three questions, goes back and changes consent to No, those three answers are not sent.

How do I end the survey when the respondent is not eligible?

Screening usually has more than one rule. Work the result out in a calculate row, then test that one field on the group. Here the survey is for women aged 15 to 49 who live in the household:

typenamelabelrequiredrelevantcalculation
select_one sexresp_sexWhat is the respondent's sex?yes
integerresp_ageHow old is the respondent?yes
select_one yes_nolives_hereDoes the respondent usually live in this household?yes
calculateeligibleif(${resp_sex} = '2' and ${resp_age} >= 15 and ${resp_age} <= 49 and ${lives_here} = '1', 1, 0)
begin groupwomen_moduleWomen's questionnaire${eligible} = 1
select_one yes_noever_pregnantHas she ever been pregnant?yes
integerlive_birthsHow many live births has she had?yes${ever_pregnant} = '1'
end groupwomen_module
noteend_screenedThis respondent is not eligible. Thank them and save the form.${eligible} = 0
surveychoicessettings
list_namenamelabel
sex1Male
sex2Female
surveychoicessettings

Keeping the rule in one calculate means the group and the closing note can never disagree, and the eligible column is in your data for the screening report. The XLSForm if statement guide covers and, or and nested conditions.

Warning:

Keep the eligible calculate outside the group it controls. A calculate inside a skipped group is blank in the submission, so the one field that explains why the interview stopped would be empty for every screened-out respondent.

How do I end the survey at more than one point?

Open a new group at each stop point and close all of them at the end of the form. Each inner group inherits the conditions of the groups around it, so you never repeat a rule. This form stops after a refusal, and stops again when the household has no child under five:

typenamelabelrequiredrelevant
select_one yes_noconsentDo you agree to take part in this interview?yes
begin groupafter_consentHousehold questions${consent} = '1'
integerhh_sizeHow many people live in this household?yes
select_one yes_nohas_under5Is there a child under 5 in the household?yes
begin groupafter_under5Child questions${has_under5} = '1'
integern_under5How many children under 5 live here?yes
select_one yes_nochild_vaccinatedHas the youngest child had any vaccination?yes
end groupafter_under5
end groupafter_consent
noteend_earlyThe interview ends here. Thank the respondent and save the form.${consent} = '0' or ${has_under5} = '0'
surveychoicessettings

Group names must be different, and the end group rows close the groups in reverse order: the last one opened is the first one closed. For how groups and their conditions work in general, see skip logic in XLSForm.

How do I end the survey based on a select_multiple answer?

A select_multiple answer is a list of every option ticked, so test it with selected() and count-selected(), not =. This form only continues for households that keep at least one kind of livestock:

typenamelabelrequiredrelevant
select_multiple livestocklivestockWhich livestock does the household keep?yes
begin grouplivestock_moduleLivestock questionscount-selected(${livestock}) > 0 and not(selected(${livestock}, '0'))
integern_animalsHow many animals does the household own in total?yes
select_one yes_nosold_animalsDid the household sell any animals in the last 12 months?yes
end grouplivestock_module
noteend_no_livestockThis household keeps no livestock. Thank the respondent and save the form.selected(${livestock}, '0')
surveychoicessettings
list_namenamelabel
livestock1Cattle
livestock2Goats or sheep
livestock3Poultry
livestock0None
surveychoicessettings

To require a minimum number of answers instead, change the group's condition to something like count-selected(${livestock}) >= 2. The guide to select_multiple skip logic explains selected(), and None of the above in XLSForm shows how to stop "None" being ticked together with other options.

How do I record why the interview ended?

Add one calculate outside every group that names the outcome. Refusals and screen-outs then arrive as ordinary submissions with a clear reason, which is what you need to report a response rate:

typenamelabelrequiredrelevantcalculation
select_one yes_noconsentDo you agree to take part in this interview?yes
integerresp_ageHow old is the respondent?yes${consent} = '1'
calculateeligibleif(${consent} = '1' and ${resp_age} >= 18, 1, 0)
calculateinterview_resultif(${consent} = '0', 'refused', if(${eligible} = 0, 'not_eligible', 'completed'))
begin groupmain_interviewMain interview${eligible} = 1
select_one yes_nohas_phoneDoes the respondent own a mobile phone?yes
end groupmain_interview
noteend_resultInterview result: ${interview_result}. Thank the respondent and save the form.${eligible} = 0
surveychoicessettings

In the export, interview_result has one value per submission, and a count of each value is your disposition table. Without it, an analyst has to work out the reason from which columns are blank.

Yes. The acknowledge type shows a single tick box and stores OK when it is ticked. Put that value in the group's condition:

typenamelabelrelevant
acknowledgeagreeI have read the consent statement aloud and the respondent agrees to take part.
begin groupafter_agreeInterview${agree} = 'OK'
textresp_nameWhat is the respondent's name?
integerresp_ageHow old is the respondent?
end groupafter_agree
noteend_no_agreeNo consent was recorded. Thank the respondent and save the form.${agree} != 'OK'
surveychoicessettings

The trade-off is in the data. An unticked box is blank, so a refusal and a question the enumerator never reached look the same. A Yes/No question records the refusal as its own value, which is the safer choice when refusals must be counted.

Common mistakes when ending a survey early

The first five messages are what pyxform and ODK Validate return, which is what you see when ODK Central, KoboToolbox or the XLSForm converter rejects the form:

MistakeFixError you will see
The consent question is inside the group it controlsMove it above the begin group rowCycle detected in form's relevant and calculation logic!
No end group row at the end of the formAdd end group after the last questionUnmatched 'begin_group'. No matching 'end_group' was found for the name 'main'.
Two groups at the same level with the same nameGive each group its own namethe 'name' value 'main' is invalid. Questions, groups, and repeats must be unique within their nearest parent group or repeat
Field name mistyped in the conditionMatch the name column exactlyReference variables must contain a name from the 'survey' sheet. Could not find the name 'consnt'.
${consent} == '1'${consent} = '1'Encountered a problem with display condition for node
${consent} = 'Yes' when the choice name is 1Compare with the choice name: ${consent} = '1'No error, but the group never opens
The eligibility calculate is inside the skipped groupMove it above the begin group rowNo error, but the value is blank for stopped interviews

The last two compile and fail silently, so test both paths in preview: one interview that goes on and one that stops. For other messages, see common XLSForm errors, or paste your form into the free XLSForm validator.

Note:

The form cannot close itself or open a new blank form. After the closing note the enumerator reaches the normal end screen and saves the form. Say this in the note, as the examples do, so nobody wonders whether a short interview should be sent.

Does this work the same in ODK, KoboToolbox and SurveyCTO?

Yes. None of the three has an "end survey" action, and all three skip everything inside a group whose condition is false. What differs is where you type the condition:

PlatformWhere the condition goes
ODK (XLSForm)relevant column of the begin group row
KoboToolbox FormbuilderSelect the questions, group them, then open the group's settings and add the rule under Skip Logic
KoboToolbox (XLSForm upload)Same as ODK
SurveyCTOrelevance column of the begin group row

The expressions themselves are the same on all three, so a form built with these examples moves between platforms by renaming one column for SurveyCTO.

Why end the interview in the form and not by instruction?

A printed rule like "if No, end the interview" depends on the enumerator stopping, and on them not filling in a few more questions out of habit. A group condition removes the choice: the questions are not there to answer. It also keeps the short interviews. Refusals and screen-outs are sent with a reason attached, so the team can report how many households were approached, how many refused and how many did not qualify, without a separate tally sheet.

Tip:

You can describe the rule in plain language instead: "end the interview if the respondent does not consent or is under 18, and record the reason". LooprAI adds the group, the closing note and the result calculate, then compiles the form with pyxform before anything is saved, so an unmatched group or a mistyped field name never reaches your form.

Build my first form free

Next: XLSForm skip logic →

Frequently Asked Questions

How do I end a survey early in XLSForm?

Put every question after the deciding question inside one group, and write the condition for carrying on in the group's relevant column, for example ${consent} = '1'. When the condition is false the whole group is skipped and the enumerator reaches the end of the form.

Is there an end survey or skip to end function in ODK?

No. ODK, KoboToolbox and SurveyCTO have no command that ends a form or jumps to the last screen. The standard method is a group with a relevant condition around the rest of the form, which skips all remaining questions with a single rule.

Will required questions stop the form from being saved after it ends early?

No. A required question only has to be answered when it is shown. Questions inside a group whose relevant condition is false are skipped, so the enumerator can finalize and send the form even though every question in that group is marked required.

Is a survey that ended early still submitted?

Yes. The enumerator saves and sends it like any other form, and it arrives with the skipped questions blank. Add a calculate outside the group that stores the outcome, such as refused or not_eligible, so these submissions can be counted and filtered in analysis.

How do I end a survey at several different questions?

Open a new group straight after each stop question and close all of them at the end of the form. Inner groups inherit the conditions of the groups around them, so each stop point needs only its own rule on one begin group row.

No Credit Card Required

Build the form first. Add hosting when you need it.

Start free with LooprAI, then deploy a managed ODK Central server or run DataSnap checks when your project is ready.

Automation handles the mechanical work.

Researchers decide what the evidence means.