Addition operand in Survey123 XLS form

2404
3
Jump to solution
07-19-2016 12:29 PM
edmundzlonis
New Contributor

Addition operand in math formula results in concatenation rather than sum for numeric
values.  I am trying to sum 4 previous fields to confirm that they add up
to 1.0. The following formula ${EC} + ${FLC} + ${OWC} + ${ShC} results in a
concatenation (0.40.30.20.1), rather than a sum (1.0) of the fields. The other
operands all work correctly. In the Excel spreadsheet the name cells for the
select_one field (e.g., PropCover) are defined as numeric and the type for the
recipient cell (TotalCover) is decimal. When I use the form with this formula
in ODK Collector the addition operand works correctly. Am I missing something?
Thanks.

0 Kudos
1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

Hi.

  Attaching new version of the survey. I used the number function to cast the decimals.

        number(${EC}) + number(${FLC}) + number(${OWC}) + number(${ShC})

  Just for fun, I also changed the appearance of the dropdowns to likert.  I got something like this. You may want to go with likert to make it faster for people to enter the data.  Likert uses a lot  of horizontal space, so I changed the labels in the choice list to get rid of the zero before the decimal places.

IMG_0841.PNG

View solution in original post

3 Replies
bobwright
Occasional Contributor

Thanks for the responses Ishmael and Hannah, but I am still unable to resolve the issue with decimal values. To summarize: Where EC = 0.2, FLC = 0.3, OWC = 0.4 and ShC = 0.3, the formula (${EC}) + (${FLC}) + (${OWC}) + (${ShC}) = 0.20.30.40.3, instead of 1.0. (The field type for the result is defined as decimal). Note that this formula works when I bring the xml form I created in Survey123 into ODK Collect on an Android device. The syntax Ishmael provided for integer values: int(${EC}) + int(${FLC}) + int(${OWC}) + int(${ShC}) does work correctly. Using this syntax as guidance, I have tried both dec(${EC}) + dec(${FLC}) + dec(${OWC}) + dec(${ShC}) and decimal(${EC})... , but keep getting formula errors when I try to update the form. Attached is the Excel spreadsheet. Thanks.

Bob

0 Kudos
IsmaelChivite
Esri Notable Contributor

Hi.

  Attaching new version of the survey. I used the number function to cast the decimals.

        number(${EC}) + number(${FLC}) + number(${OWC}) + number(${ShC})

  Just for fun, I also changed the appearance of the dropdowns to likert.  I got something like this. You may want to go with likert to make it faster for people to enter the data.  Likert uses a lot  of horizontal space, so I changed the labels in the choice list to get rid of the zero before the decimal places.

IMG_0841.PNG

bobwright
Occasional Contributor

Thanks for the help and the suggestion!