Using two variable names under the Trigger column

1. What is the problem? Be very detailed.

I would like to use two variables under the Trigger column since I have two options/scenarios that could happen depending on a condition.

  1. I have two types of household visit (First visit and Revisit).
  2. Any type of visit you chose requires that you key-in the number of households or structures in that compound.
  3. If the respondent erroneously said there are 5 households, you would be required to give information for all the households even if there were only 3 households.
  4. I need to use ${first_visithouseholds} ' , ' ${revisit_households} questions to serve as the trigger under the Trigger column so that I can go back and change number of households from 5 to 3 households to recalculate so that the repeat function does not ask for 5 households but instead ask for 3 households.

2. What app or server are you using and on what device and operating system? Include version numbers.

I am using ODK collect v1.25.2 on a Samsung Tab4 using Android version 4.4.2

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

I introduced a third row ${total_households} that calculates (sums the two options, if(${firstvisit_households}=null,0,${firstvisit_households})+if(${revisit_households}=null,0,${revisit_households})

Then used the ${total_households} variable under the Trigger column, but because its not a visible question, I am getting an error when I use the Online XLSForm converter (Error: The question ${total_households} is not user-visible so it can't be used as a calculation trigger for question ${position1}.)

4. What steps can we take to reproduce the problem?

Is it possible to use two visible questions under the Trigger Column to help avoid this error?
(Error: The question ${total_households} is not user-visible so it can't be used as a calculation trigger for question ${position1}.)

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.trigger_test_Saduma.xlsx (10.7 KB)

Is a new form submission filled out for each visit? That is, does the data collector fill out the form once for the first visit and fill the form a second time for a revisit?

Yes, @danajoseph, that's true

In the data, how do you plan on linking the survey submissions to a single compound? Maybe you will need some sort of question to select the name of the compound. I don' think you need the calculation for the buildings to be mapped, just have:

  • a question to record which compound
  • a question to record which type of visit
  • a question to record building being mapped during that visit
  • if you want, you can include an acknowledge type question to have the surveyor confirm the number they entered before continuing
  • I would also include some metadata like today

Then in your data table you can use filters and sorting to get any of your statistics. If you need all buildings mapped on a first visit you can filter by the "type of visit" column and count the building mapped in the remaining rows. If you want the total buildings for a compound, you can filter on the compound question and count the buildings mapped in the remaining rows. Etc...

On the revisit how does the surveyor know which structures were mapped before on the first visit? If you fill out a separate form for each building (instead of using a repeat group) and collect a geo-point you could then see which buildings you've completed on a map on the phone. See the page for https://docs.getodk.org/collect-form-map/.

Screen Shot 2021-01-29 at 8.38.58 AM

This particular question wasn't addressed, and I was attempting to trigger using one of two user input fields eg ${field1} or ${field2}, but adding the second field caused the calculation not to occur at all.

Is this supposed to work / not supported? If not, is there another way to trigger off >1 user input fields?

The docs don't indicate that it is/isn't possible

There's currently no way to do this with XLSForm.

Under the hood, using the trigger column generates a setvalue action targeting the field represented by that row. The calculation in that row is triggered by an xforms-value-changed event when the node referenced in the trigger column changes.

In the raw XML, you can have setvalue actions targeting the same field based on multiple xforms-value-changed events.

Thanks @LN! Manipulating the XML with every form update isn't practical so I'll see if I can work around needing to trigger off >1 fields.

1 Like