Hi,
How do I calculate values, taken as input in repeat groups? For example, I have a repeat group and I would like it to be repeated 3 times and I will provide 3 values for 3 repeats. After repeats, How do I calculate values from the repeat groups?A form is attached here for your input.
Thanks,
Imran
repeat_group.xlsx (9.6 KB)
2 Likes
jruizc
October 27, 2017, 4:40am
2
Hi,
I would use indexed-repeat in the case you have a constraint for the number of repeats allowed.
In your example, you have a maximum of 3 repeats, meaning you would need 3 calculate rows like this:
+--------------+--------------+-----------------------------------+---------------------------------------------+-----------------+
| type | name | label | calculation | repeat_count |
+--------------+--------------+-----------------------------------+---------------------------------------------+-----------------+
| integer | total_people | How many people will be surveyed? | | |
| begin_repeat | repeat_name | Group 1 | | ${total_people} |
| integer | value | Value: | | |
| end_repeat | | | | |
| calculate | calculate_1 | | indexed-repeat(${value}, ${repeat_name}, 1) | |
| calculate | calculate_2 | | indexed-repeat(${value}, ${repeat_name}, 2) | |
| calculate | calculate_3 | | indexed-repeat(${value}, ${repeat_name}, 3) | |
+--------------+--------------+-----------------------------------+---------------------------------------------+-----------------+
3 Likes
Hi Jorge,
Thanks for your response. I am wondering how do I manage if the number of repeats is not defined. For instance: a user may select 3 repeats other may select 5 repeats.
Thanks once again,
Imran
1 Like
LN
October 27, 2017, 3:38pm
4
You can use the sum
function to sum all the values with a given name
in a repeat
. See an example based on what you shared here .
6 Likes
Hi Hélène,
Thanks so much. This is so helpful.
Imran
1 Like
LN
Split this topic
June 20, 2018, 6:10pm
6
Hi,
Did you ever figure out how to store variables to calculate dynamically based on the number of count?
THank you