Select to view content in your preferred language

Passing data from repeat question based on specific response

480
2
05-23-2023 08:59 PM
Labels (1)
suhendra0812
New Contributor

I've been working on Survey123 form with the repeat question. In the repeat question, there are 2 questions namely "Scoring Criteria" and "Score". In the "Scoring Criteria" question there are the following choices: A, B and C. In the main question, there are columns "Score A", "Score B" and "Score C". I want to pass the value from the "Scoring" response in the repeat question to the "Score" field in the main question based on the selected criteria.

This is my XLSForm configuration:

The XLSformThe XLSform

This is the expected result:

Expected ResultsExpected Results

This is the given result:

Given ResultsGiven Results

In addition, how to prevent multiple responses be submitted based on the criteria in the repeat question?

 

 

0 Kudos
2 Replies
ChristopherCounsell
MVP Regular Contributor

I'm not sure if you need a repeat here if you have a set of questions and a set amount of repeats. But anyway.

What you can do is use the below to refer to a question within a specific repeat:

indexed-repeat(question, repeat, index number)

You should also consider the repeat_count to limit the number of repeats (e.g. 3 for A, B and C).

You can also consider calculation modes in the bind parameters, if the calculations are not re-triggering.

abureaux
MVP Regular Contributor

If you have a look at the Samples in Connect, the one for JavaScript has a use-case almost identical to what described above. The difference is that it is calculating Standard Deviation.