Select to view content in your preferred language

Calculations concatenating instead of providing mathematical result

620
2
07-04-2023 09:13 AM
BryceHancock
Occasional Contributor

I have a form, screenshot attached, with a series of calculations to compute a final result.  The first set of calculations work fine, but when I attempt to sum the results of two calculations then compute an average, the values are concatenated instead of computed. I tried setting bind esri field type to integer and also tried beginning each expression with int( as I found an article stating the calculation fields are saved as strings, so I assumed my final result fields are being treated as strings and concatenated instead of summed. The result stopped evaluating all expressions and provided results from only a single series of the expressions instead of summing and averaging the results. How can I correct the attached expressions to compute the sum and average of the 2 series of fields?

The xls form I am using is an older version, I pulled to from a previous survey to use as a template. Could this be causing the issue?

0 Kudos
2 Replies
fklotz
by
Occasional Contributor

Personally I don't like "Hidden" or "Calculate" fields.  I suggest the following: For the questions which are doing math which you are not showing to the end user, set them as Decimal question types (I do my conversion to integer at the last stage to better control the outputs), set the "bind::esri:fieldType" to null, set the "body::esri:visible" to 1=2 (or some other expression which will make them invisible).  This way you don't end up with the oddities that calculate or hidden question types and hidden appearances bring and you end up with math that works without having to insert random int() functions or setting the "bind:esri:type" which I've had cause other issues in the past.

Note, it is often easier if you post your excel, or a subset of it instead of a screen capture.  It makes it much easier to provide assistance.  e.g. attached is what I did to confirm my recommendation for this question.

 

Farley
0 Kudos
abureaux
MVP Regular Contributor

I am of the opposite mind. I very much prefer "Calculate" fields. "Hidden" fields have their place, but I likely wouldn't use them in this context. 

@BryceHancock Try changing bind::type rather than bind::esri:fieldType. If that doesn't work, could you please provide your XLSX form as that would make this process much easier. Your approach does sound correct, but it's hard to tell what's going on without the XLSX form.