Select to view content in your preferred language

Survey123 connect - How to sum triple nested repeat fields in the parent

133
4
a month ago
Lisa_G
by
Occasional Contributor

Hi,  I have a Survey123 Connect (v3.19) form that has a triple nested repeat. I need to sum() fields from the repeats, in the parent.

I can find information on how to do this with just one repeat. The sum fields I have created are not returning correct data. Can anyone explain to me how to sum across a triple nested repeat?

I have 3 nested repeats, Locations, Health Hazards and Personal Property. I did create a new field in the parent (outside of all the repeats). I want to sum a field from the Health Hazards repeat. Total_of_flammables is the field I created in the parent. Under Calculation field, sum(${flammables_count}) is how I wrote it. Do I need to call the repeat name as well? I can't find any exact instructions for creating a sum across triple nested repeats. Any help would be appreciated. Thank you.

0 Kudos
4 Replies
MattEdrich
Frequent Contributor

Hello, I think I can help with this. I suspect you may need to add some `calculate` fields to your nested repeats to make the sums of each level available to higher levels of the survey. If you are able to share your XLS form with me, I am happy to experiment locally and see what I can do!

0 Kudos
Lisa_G
by
Occasional Contributor

Hi Matt,

Thank you for your offer of help. The xls form is rather large. There are 3 nested repeats, and the parent.

0 Kudos
DougBrowning
MVP Esteemed Contributor

I do this in several forms.

You need to sum at each level of the repeats.  

You have a parent, child, grandchild if triple nested.  Add a sum() at the child level that sums up the grandchildren then add a sum at the parent level that sums up the child sum field.  This will get them all.

Hope that helps

Lisa_G
by
Occasional Contributor

Hi Doug,

 

Ok, thank you for your direction for adding repeat sum() at child and grandchild levels. I will give it a try. Thank you very much!