Help am new to ODK am trying to make am trying to make the total auto calculate the sum of male and female.please can some one show me how the calculations are done
Ok I found out a possible issue. With the form attached before.
Having the calculation shown on the same page doesn't really work (it works in enketo).
You could force to go to the end and save the form and then the value total will be saved.
To see the value of the calculation then the sum must be placed outside the group.
Maybe a bug of collect? @Grzesiek2010
I think you can do it using a note with the fieldlist:
in your spreadsheet line 25 use the following
change Type from integer to note
change the label from "Total" to "Total ${total_calc}" (my quotation marks!)
This worked for me on a different form that I had been scratching my head over, wanting to see a calculation on screen... When you upload the data there will be a column for "total_calc", so you don't need to have the integer as well
Apologies - I was responding to this statement - I understand it is a workaround, but does that mean that the integer type needs to be fixed? Perhaps it is a similar issue to cascading selects and field-list? There is a warning about this in the docs, and you have highlighted that in your answer:
That's why I thought a workaround might be helpful, as it could mean major refactoring (not that I would be averse to that change!).
You would probably also need to set an integer to read-only, or perhaps find some confusing data if someone changed the value (it might recalculate on save?). It would also result in an additional column in the dataset that has the same value as the calculate one (using a note still adds a column to the uploaded data, but it is blank).
Not trying to be critical of your answer, but I was thinking of it from a data management perspective as well as functionality in the field - being Stupid, I like to Keep It Simple
This issue was already discussed in a different topic.
@seewhy reply is correct.
You are performing a calculation in row 25 (${total_cal}).
The calculation in row 26 is redundant per se, and should be removed (you cannot enter an integer and perform the calculation at the same time).
Depending on what you want to achieve, you would need to edit row 26.
a) if for some reason you want to validate the total entered by the user, you need to enter .=${total_calc} in the constraint field
b) if you want to display to the user the total (i.e. automatic calculation) you would write ${total_calc} in the label field.