Hidden field calculation with questions nested in folder with display condition that doesn't trigger

Hi CommCare fam,

Wondering if someone might help me figure out where I am going wrong with a hidden field calculation.

I am designing an app which will be used to digitize paper data. One of the questions in the form is "How many communities were visited?" with a maximum of 5.

I made a folder of questions to collect number of services conducted. Based on the numbers input, there is a hidden field calculation (ex: if 10 condoms were distributed, 10*0.0083 to get the CYP).

In order to avoid repeat groups, I created 5 replicas of this initial set of questions/calculations, to display depending on the number of communities visited (1-5).

At the end of the app, I have a set of hidden field calculations in a separate group/folder that would sum the various indicators across these groups/folders. However, I am finding that these calculations "break" unless the user responds that they visited 5 communities, and subsequently they fill in all questions for all five folders/groups. If they only visit 2 communities and subsequently record data for 2, the within-folder/group calculations work, but the end-point/aggregating indicators at the end show blank.

Any ideas how I can work around this?


Hi Stephen,

How are you adding up the aggregate values?

If you are doing the straightforward thing (IE: #form/g1/q1 + #form/g2/q1 ...) you might try wrapping the individual questions with the coalesce() function which will give you an easy place to specify the 'default' answer for a blank value.


coalesce(#form/g1/q1, 0) + coalesce(#form/g2/q1, 0)...

1 Like

Hi Clayton,

Thanks so much for the quick reply, and helpful solution! That did the trick, thank you so much!