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)