Help with multiplication in Survey123

258
6
04-17-2019 11:39 AM
Highlighted
New Contributor

Hi, I am trying to do simple multiplication in Survey123, and it keeps giving me the wrong answer when I plug in numbers on the Template. I am trying to find Purge (gallons), so I have DTW (ft), DTB (ft), and Diameter (inches). The equation to get Purge is DTB-DTW = water column and then you multiply water column by the conversion (if diameter is 2, conversion is 0.68, if diameter is 4, conversion is 1.98, and if diameter is 6, conversion is 4.5).

This is what I have: ${DTB} - ${DTW} to get water column. Then you choose the diameter (either 2, 4, or 6). Then, you choose the conversion (either 0.68, 1.98, or 4.5). Then for my Purge column, I have ${waterColumn} * ${conversion}. I got no errors when I saved it, but when I tried an example, I got a wrong answer.

I tried DTB = 65.80, DTW = 39.46, diameter = 6, and conversion was 4.5. My water column came our correctly (26.34), but Purge keeps coming out as 79, even though 26.34*4.5 = 118.53. What am I doing wrong?

Reply
0 Kudos
6 Replies
Highlighted
Esri Frequent Contributor

Hi Mike,

Can you please share your survey xslx file so we can take a closer look?

Are all the questions of the same type (ie integer or decimal) or do you have text or select one questions as part of the calculation? If so you need to use the bind type column to set them as "int" and also you may need to cast them as "int" in the calculation to ensure all the values are being converted correctly.

Phil.

Reply
0 Kudos
Highlighted
New Contributor

(ignore the truck, it's dual monitors). Here is my xslx file. I'll try to mess around with the bind type column. Let me know if you notice anything else that could be going wrong, thank you!

Reply
0 Kudos
Highlighted
Esri Frequent Contributor

Hi Mike,

Yes, from a quick look the problem is due to using the ${conversion} field, which is a select_one so text type by default, in a numeric calculation. Set the bind::type of this select one field to "int" and also in the calculation trying putting int(${conversion}). Do the same for any other text or select one you are trying to use in calculations.

Phil.

Reply
0 Kudos
Highlighted
New Contributor

Hi Philip,

Thanks for the help. However, I have a new issue now. I made just the changes you mentioned above and when I try to save it, I get Error convering XLSForm when I try to save the XLS. Any idea why this could be?

Thanks!

Reply
0 Kudos
Highlighted
New Contributor

Reply
0 Kudos
Highlighted
Esri Frequent Contributor

Hi Mike,

Sorry for the delay in getting back to you. The issue you are now encountering is actually a known bug with trying to apply a bind type to a select one question. It is not currently supported and throws an error. Sorry I should have realised this before sending you the previous solution. We have a known bug in our backlog for this and I have added your comments and use case to the issue.

The way to workaround this is to use another field after the select one, an integer/text field for example, that is a calculation based on the select one. Basically all you are doing is displaying the value from the select one in a field other than a select one type. You can then use the bind type on this question to ensure it is treated as an integer, and use this field name in your calculation. You can also make it null or hidden, so that it is not displayed in the form or stored in feature layer, but just exists to help with the calculation. 

If you need help with this or still have issues, please send me your xslx form file (attach to the reply) and then I can take a closer look at your form and update where needed with an example. It is easier than sharing a screenshot of your form. You may need to open the "Use advanced editor" option in reply window to attach files.

Phil.

Reply
0 Kudos