Conditional counting on repeats

Hi all,

I got a question a few days back about how to count people in a repeat
who are older than five. It was a fun form to build, so I figured I'd
share the solution with the community.

The general strategy for conditional counting is to use two repeats.
The first repeat is a normal repeat that collects all the people. The
second repeat is a hidden repeat with the same number of repeats from
the first. We do this in the repeat_count column with a
count(${first_repeat}).

Then use indexed-repeat inside the second repeat to extract each
person's age and use a calculate with some dummy value that is only
relevant when age is above five. Count those dummy values to get the
number of persons over five.

I know it sounds very complicated in an email, but I promise it's not.
Try the attached form and let me know if you have any questions!

Yaw

conditional_count.xlsx (10.8 KB)

2 Likes

Thanks so much. i really needed something of this kind. Good job man.

1 Like

Probably this attached form will give the same result.sum_count_from_repeat.xlsx (9.2 KB)

1 Like

Interesting, thank you Yaw.