Conditional sum of integers from nested repeat groups

Hi KoBoToolbox community. Hoping someone can help me with this.

With reference to the attached screenshot, I am trying to sum up the total pieces for each fruit bought from different purchase (i.e., purchase period or purchase channel). For this, I initially created a repeat group (purchases) within another repeat group (pieces), but I am having a difficulty in doing the sum portion given the challenge coming from the undefined repeat loops and options in the select-multiple question.

Welcome to the community, @hm11! Maybe this post discussed previously should help you solve your issue:

hi @Kal_Lam , thank you for your response. however, I think this example only works with single select question type. in my case, it is multiple select and I am currently working on extracting on the pieces input per fruit for the summation. I have tried combining skip logic for multiple select and indexed-repeat so far, but it’s still not working. for your further assistance please

Hi @hm11 ,
I came across your post and I was wondering whether you found a workaround that solved the issue?
I think I am facing the same, I have a multiple select in the beginning of a repeat group and I have difficulties to calculate the sum. Based on what was described in this post https://community.kobotoolbox.org/t/cumulative-sum-of-repeat-group-calculation/296/2, I managed to make it work as long as all options of the multiple-select are selected, in each loop. But this will rarely be the case.
Hi @Kal_Lam, is there no way around this when including a multiple-select?

Here is a screenshot of my example, various student groups are entered with details on the number of boys and girls in a group. (it only shows a reduced selection of fields and options for the select-multiple. In the original more details need to be filled in that make both the multiple-select and loop necessary)

hi @Frieda, here’s a screenshot on what worked for me. I hope this helps.

Hi @hm11, thanks for your reply. I will have a look at your solution.


Hi KoBoToolbox community. Hoping someone can help me. With reference to the attached screenshot, I am trying to sum up the total of hours for each household member, the total of hours registered from different member (i.e., member nº1, member nº2...). I initially created a repeat group (miembros) within another repeat group (registro_actividades), but I am having a difficulty in doing the sum of hours per member, because it doesn't add the total hours per member but it gives me the grand total. Can you help me? thank you.

koboquestion.xlsx (16.4 KB)