ODK xlsform design, calculate next label value based on previous yes_no response

551 views Asked by At

I'm working on a survey questionnaire using xlsform for ODK. Where I'm stuck: I have a questions on the from like this: 21. Are you willing to pay for the service if it was offered at $100? The answers can be either Yes, No, or Dont know. If the respondent says Yes, the next Question will need to add $20 to the previous $100 so the question should now read as: 21. Are you willing to pay for the service if it was offered at $120? This should continue until the respondent says No. How can I implement this using xlsform design?

1

There are 1 answers

0
Luise On

I understand that you need a repeat select_one loop that goes until No is selected. There is a way to do that through the indefinite-repeat XLSForm.

This is an application of it to your question:

enter image description here

Explanation:

  • The count variable is keeping track of how many times your form repeats your question.
  • The repeat_count field in loop_question states that your repeat should go on if (i) the repeat has ran zero times, or (ii) as soon as the answer "no" is registered in willing_pay.
  • The variable amount calculates the amount you should be showing in willing_pay.

Hope this helps.