Need Assistance with Implementing Skip Logic and Random Selection Based on a Calculated Field in XLSForm

Hello KOBO Community,

I am working on a survey form where I need to implement some conditional logic and actions based on respondents’ answers to a set of initial questions. Specifically, my challenges are twofold:

  1. Skip Logic Based on a Calculated Field (CON): I have a section where respondents answer questions about their familiarity with certain procedures (labeled Q1_A to Q1_E, with responses coded as 1 or 2 for familiarity). Based on these responses, I calculate a field (CON) to count how many procedures they are familiar with. I need to implement logic where:
  • If CON = 0, the survey skips to question Q15, bypassing questions Q2 to Q14.
  • If CON > 3, I need to randomly select two of the procedures they are familiar with for follow-up questions.
  1. Random Selection of Services for Follow-Up: For respondents familiar with more than three procedures, I wish to randomly select two for further questions. I am seeking a method to achieve this random selection within the constraints of XLSForm and KOBO’s functionalities.

I’ve managed the calculation for CON in a calculate field using the following formula:
if(${Q1_A}=‘1’ or ${Q1_A}=‘2’, 1, 0) + if(${Q1_B}=‘1’ or ${Q1_B}=‘2’, 1, 0) + if(${Q1_C}=‘1’ or ${Q1_C}=‘2’, 1, 0) + if(${Q1_D}=‘1’ or ${Q1_D}=‘2’, 1, 0) + if(${Q1_E}=‘1’ or ${Q1_E}=‘2’, 1, 0)

However, I am unsure how to best implement the skip logic and random selection based on the CON value. I am particularly stumped on how to execute the random selection of two services for those with CON > 3 within the XLSForm syntax or if there’s a workaround that complies with KOBO’s capabilities.

Any advice, examples, or guidance on how to tackle these issues would be greatly appreciated. Specifically, I am looking for XLSForm syntax or logic strategies that others have successfully used in similar scenarios.

Thank you in advance for your help and insights!

Welcome to the community, @kujtak!

Regarding query 1:

This post discussed previously should help you solve your issue:

Regarding query 2:

This post discussed previously should help you solve your issue: