Default integer based on previous integer input

1. Problem
I have 2 sets of 12 integer type questions:

  • "How many children enrolled " by grade & gender
  • "How many children attending on day of visit" by grade & gender

I would like to populate the second set of questions based on answers to the first set of questions (default, the user can change the number).

I already have a constraint, but it would aid the monitor very much to have this prepopulate and he/she just adjusts the numbers for grades with missing kids.

2. What app or server are you using and on what device and operating system? Include version numbers.
ODK Collect v.1.29.5 ; ONA-based server

3. What you have you tried to fix the problem?

  • directly referenced the field
  • referenced the field with sum()
  • used calculations as reference (just the field, sum(field), if(field=null,0,field)
  • used triggers for calculations

See the xlsform attached with everything I've tried so far.
example_school.xlsx (21.9 KB)

The ODK & Mobile Data Collection community have helped me design killer forms in the past, so hope some wonderful mind out there may have a solution :slight_smile:

Thank you!

Hi @Daria_Gordina
here Form Logic — ODK Docs everything is well described how to use dynamic defaults.
If it's not clear please let us know.

1 Like

@Grzesiek2010 looking with fresh eyes now everything is clear :slight_smile:

Before for some reason I thought you need to first create a calculate field, and then input the calculate field into the default column. Now I realise you just add to the calculation column directly, no need for extra fields. Sometimes all you need to do is ask :wink:

1 Like