Are Boolean and mathematical operators allowed in the same formula? (Or & div)

133
4
Jump to solution
02-12-2019 03:34 PM
Highlighted
New Contributor II

I'm working on a survey that calculates the value radius based on a diameter value that changes depending on another part of the form. In Survey123 Connect on Windows the first scenario works but it does not work on a web form. The second scenario works in both Windows and the web. Should the first one work in both places? 

It appears the inner parentheses is always evaluated to 1 in scenario 1, regardless of the terms.

Scenario 1: Round Pipe with Boolean

variables

decimal DIAMETER_ROUND set to 5.5

decimal HORIZONTAL is null and hidden by relevancy

formula

double RADIUS calculate (${DIAMETER_ROUND} or ${HORIZONTAL}) div 2

results

Windows: 2.75 (correct)

Web form: 0.5 (wrong)

Scenario 2: Round Pipe with if/then

variables

decimal DIAMETER_ROUND set to 5.5

decimal HORIZONTAL is null and hidden by relevancy

formula

double RADIUS calculate if(${PIPE_SHAPE}="round",${DIAMETER_ROUND} div 2,${HORIZONTAL} div 2)

result

Windows: 2.75 (correct)

Web form: 2.75 (correct)

Tags (1)
1 Solution

Accepted Solutions
Highlighted
Esri Esteemed Contributor

Hi Elliott,

I don't think I would expect the first formula to work properly - the part

(${DIAMETER_ROUND} or ${HORIZONTAL})

creates a true/false comparison.  In the interpreter used by the field app, this yields the first non-null value (a quirk of javascript).  The web form adheres to a more strict definition and returns true or false only - in javascript, this gets converted to 1 or 0 for the division step.

View solution in original post

4 Replies
Highlighted
Esri Esteemed Contributor

Hi Elliott,

I don't think I would expect the first formula to work properly - the part

(${DIAMETER_ROUND} or ${HORIZONTAL})

creates a true/false comparison.  In the interpreter used by the field app, this yields the first non-null value (a quirk of javascript).  The web form adheres to a more strict definition and returns true or false only - in javascript, this gets converted to 1 or 0 for the division step.

View solution in original post

Highlighted
Frequent Contributor II

Yea i agree.  You can test the fields to see if they are hidden using ''.

So 

if(${DIAMETER_ROUND} != ''; ${DIAMETER_ROUND} div 2, ${HORIZONTAL} div 2)

Just like your second statement.

Highlighted
New Contributor II

Thanks. Does the '' test work on integers or float/double variables?

Reply
0 Kudos
Highlighted
Frequent Contributor II

yep i think so

Reply
0 Kudos