Calculations over Repeating Groups

I'm new to XLSForms and was wondering if any could help me. I am looking to
sum up a group of 20 repeating questions (there's no constraint on how many
times it could be repeated). I need it to sum up each time and then also
the sum total. In the example below, let's say that the group of 4
questions was repeated 3 times. I need the individual scores each time as
well as the total sum after it was repeated 3 times.

*SUM001- *8
*SUM002- *2
*SUM003- *8
*TOTAL_**SUM001- *18

EXAMPLE

Q1. Does the scale hang on an immobile platform?
Yes - 2 points
No - 0 points

Q2. Is the scale calibrated to 0 including weight of harness?

Yes - 2 points
No - 0 points

Q3 Is heavy clothing removed before weight was taken?

Yes - 2 points
No - 0 points

*Q4. Is the infant seated correctly in the harness (one arm situated in
front of one harness strap and the other behind the opposite strap or in
some way balanced in the harness)?*Yes - 2 points
No - 0 points

Hi Ann,

A $total prompt with a calculate of $sum1+$sum2+$sum3 will give you
the sum inside the repeat. Then outside the repeat, sum($total) will
give you the sum of all the $totals.

Try it with a very small form and see how that goes.

Yaw

··· -- Need ODK consultants? https://nafundi.com provides form design, server setup, in-field training, and software development for ODK.

On Wed, Oct 28, 2015 at 4:53 PM, Ann D ann@theihanganeproject.com wrote:

I'm new to XLSForms and was wondering if any could help me. I am looking to sum up a group of 20 repeating questions (there's no constraint on how many times it could be repeated). I need it to sum up each time and then also the sum total. In the example below, let's say that the group of 4 questions was repeated 3 times. I need the individual scores each time as well as the total sum after it was repeated 3 times.

SUM001- 8
SUM002- 2
SUM003- 8
TOTAL_SUM001- 18

EXAMPLE

Q1. Does the scale hang on an immobile platform?

Yes - 2 points
No - 0 points

Q2. Is the scale calibrated to 0 including weight of harness?

Yes - 2 points
No - 0 points

Q3 Is heavy clothing removed before weight was taken?

Yes - 2 points
No - 0 points

Q4. Is the infant seated correctly in the harness (one arm situated in front of one harness strap and the other behind the opposite strap or in some way balanced in the harness)?

Yes - 2 points
No - 0 points

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups "ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

For repeat groups, if $field1 is a numeric field in the repeat, you can
sum up all values entered into that field, across all repeat instances, by
using:
sum($field1)

Note, however, that the values in all choice lists are strings, not
numbers. So if you map "Yes" to 1, and "No" to 0, you are actually mapping
these to "1" and "0", not the numbers 1 and 0. i.e., sum($field1), where
$field1 is a select1 prompt, will fail because it is trying to sum over a
set of string values.

The solution is to have a calculated field immediately after the select1
prompt to store the value from that field as a number. I.e., a calculated
field "fieldN1" with a calculate expression of int(../field1) will
convert the value of field1 to an integer and store it in fieldN1. You can
then sum those fields using sum($fieldN1)

··· On Wed, Oct 28, 2015 at 7:34 PM, Yaw Anokwa wrote:

Hi Ann,

A $total prompt with a calculate of $sum1+$sum2+$sum3 will give you
the sum inside the repeat. Then outside the repeat, sum($total) will
give you the sum of all the $totals.

Try it with a very small form and see how that goes.

Yaw

Need ODK consultants? https://nafundi.com provides form design, server
setup, in-field training, and software development for ODK.

On Wed, Oct 28, 2015 at 4:53 PM, Ann D ann@theihanganeproject.com wrote:

I'm new to XLSForms and was wondering if any could help me. I am looking
to sum up a group of 20 repeating questions (there's no constraint on how
many times it could be repeated). I need it to sum up each time and then
also the sum total. In the example below, let's say that the group of 4
questions was repeated 3 times. I need the individual scores each time as
well as the total sum after it was repeated 3 times.

SUM001- 8
SUM002- 2
SUM003- 8
TOTAL_SUM001- 18

EXAMPLE

Q1. Does the scale hang on an immobile platform?

Yes - 2 points
No - 0 points

Q2. Is the scale calibrated to 0 including weight of harness?

Yes - 2 points
No - 0 points

Q3 Is heavy clothing removed before weight was taken?

Yes - 2 points
No - 0 points

Q4. Is the infant seated correctly in the harness (one arm situated in
front of one harness strap and the other behind the opposite strap or in
some way balanced in the harness)?

Yes - 2 points
No - 0 points

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google
Groups "ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com