I am using a series of questions to calculate the amount of water that a household uses each day, per water container. I am using a simple calculation to multiply the input for “container capacity” and “number of times container was filled.” I am doing this in a repeat group so that multiple water containers can be counted. I am now trying to calculate a cumulative sum of the calculations (total water used, across all containers).

In CommCare, I am able to accomplish this with a simple “sum” function, but I cannot seem to get the same effect in KoBo. How can I do this in KoBo?

Done several calculate functions with KOBO forms my advice would be you purse the number of times this can happen in a question construct and then apply the multiplication function for the same… as it repeat questions have an indefinite nature which makes it hard to compound a calculation…

I am using a series of questions to calculate the amount of water that a household uses each day, per water container. I am using a simple calculation to multiply the input for “container capacity” and “number of times container was filled.” I am doing this in a repeat group so that multiple water containers can be counted. I am now trying to calculate a cumulative sum of the calculations (total water used, across all containers).

In CommCare, I am able to accomplish this with a simple “sum” function, but I cannot seem to get the same effect in KoBo. How can I do this in KoBo?

Thank you in advance,
Lauren

–

You received this message because you are subscribed to the Google Groups “Kobo Users” group.

There is a way to do the same, but with a caveat that no element can be empty, otherwise sum() will (correctly) return NaN (in that respect KoBo’s Enketo is a bit stricter than Commcare). You can achieve this by using a calculated item such as this: “if(${container_capacity} > 0 and ${number_containers_filled} > 0, ${container_capacity} * ${number_containers_filled}, 0)” inside the repeat, and sum() the values of this calculated item.

On Monday, December 22, 2014 1:10:37 PM UTC-7, Kenyan Aloo wrote:

Hi Lauren

Done several calculate functions with KOBO forms my advice would be you purse the number of times this can happen in a question construct and then apply the multiplication function for the same… as it repeat questions have an indefinite nature which makes it hard to compound a calculation…

I am using a series of questions to calculate the amount of water that a household uses each day, per water container. I am using a simple calculation to multiply the input for “container capacity” and “number of times container was filled.” I am doing this in a repeat group so that multiple water containers can be counted. I am now trying to calculate a cumulative sum of the calculations (total water used, across all containers).

In CommCare, I am able to accomplish this with a simple “sum” function, but I cannot seem to get the same effect in KoBo. How can I do this in KoBo?

Thank you in advance,
Lauren

–

You received this message because you are subscribed to the Google Groups “Kobo Users” group.