# Calculating with select one yes_no

1. What is the problem? Be very detailed.
I am finding it difficult to calculate or sum up a group of selected yes or no function in the form.

2. What you have you tried to fix the problem?
select_one yes_no a_1_1_1 Availability of grass on the compound list
select_one yes_no a_1_1_2 Grass should be green list
select_one yes_no a_1_1_3 Not mixed with weeds (other grasses) list
select_one yes_no a_1_1_4 Area well ‘boxed’ by kerbs list
select_one yes_no a_1_1_5 Grass cut (mowed) very low list
select_one yes_no a_1_1_6 No bare area list
calculate scores_Display [within the Calculation Column] scores_Display = \${a_1_1_1} +\${a_1_1_2}+\${a_1_1_3}+\${a_1_1_4}+\${a_1_1_5}+\${a_1_1_6}

note display_Scores Scores: \${scores_Display}

end_groupenvironment_and_infrastructure.xlsx (15.8 KB)

scores_Display = \${a_1_1_1} +\${a_1_1_2}+\${a_1_1_3}+\${a_1_1_4}+\${a_1_1_5}+\${a_1_1_6}

As the formula in the Calculation field, remove "scores_Display =", which should leave it as:

\${a_1_1_1} +\${a_1_1_2}+\${a_1_1_3}+\${a_1_1_4}+\${a_1_1_5}+\${a_1_1_6}

This is demonstrated in the calculation section of the docs

1 Like

I did so but the result is not showing in the Scores Row

Please edit row 13 and 14 according to this:

environment_and_infrastructure.xlsx (11.3 KB)

the score will be shown once you answers all questions.

According to this topic, the problem might be that the calculation is trying to add up string variables.

This should work with both the number() and int() functions; try with:

int(\${a_1_1_1} )+int(\${a_1_1_2})+int(\${a_1_1_3})+int(\${a_1_1_4})+int(\${a_1_1_5})+int(\${a_1_1_6})

Not working as described

Just FYI, this doesn't actually matter - XPath evaluation of expressions will automatically 'typecast' their operands appropriately; ie "`\${A} + \${B}`" will implicitly be evaluated as "`number(\${A}) + number(\${B})`"

See XPath 1.0 spec for the (gory) details:

3.5 Numbers

...

The numeric operators convert their operands to numbers as if by calling the number function.

...

1 Like

`Not working as described...` is not very helpful taking into account that YOU need help please try to explain what's wrong instead. I tested it and it added 1 point for each yes. Did you get something else?

1 Like

Can you please describe what is not working with @Grzesiek2010 form? If you load his form into XLSForm online and run it (under Enketo) you will see that it is correctly displaying the total for the first section:

[its left as an exercise to to the reader to replicate what he's done over the other sections if you want the same behavior]

1 Like

Thanks it is now working! Sorry not knowing I was still working with the old file.
Thank you!