Survey123 Calculated Fields Different in Web and Device

385
1
Jump to solution
09-21-2021 01:49 PM
DirkVandervoort
Occasional Contributor II

I have a TEXT field with a calculated value: The value is based on the selected value of a SELECT_ONE field named “structure_type”. The calculation is essentially serial string of if statements checking the selected value of “structure_type” and calculating the value of the TEXT field to some value.

if(selected(${structure_type}, "B-85"), "34 ft 7 in", "") or if(selected(${structure_type}, "B-85OP"), "34 ft 7 in", "") or if(selected(${structure_type}, "B-90"), "34 ft 7 in", "") or ...

 

In a device Survey123 the TEXT field is correctly calculated:

DirkVandervoort_0-1632257270208.png

 

In the web Survey123, the TEXT field is incorrectly calculated:

DirkVandervoort_1-1632257270211.png

 

 

Note that the web Survey123 treats the calculation as a Boolean, whereas the device Survey123 performs the desired calculation.

My question is: How can I perform the calculation correctly on both the device and the web?

 

TIA

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

I have seen this posted.  It has to do with the calc having or in it - the app will auto concat all of these but the web will not.

All you results are the same so not sure what you want here.  Your statement is not written correctly either way really.  The app just let you cheat it.

If they are all the same result text then it should be written like

if(selected(${structure_type}, "B-85") or selected(${structure_type}, "B-85OP") or selected(${structure_type}, "B-90"), "34 ft 7 in", "")

If the values are diff you would use nested if statements.

if(selected(${structure_type}, "B-85"), "34 ft 7 in", if(selected(${structure_type}, "B-85OP"), "35 or something ft 7 in", if(selected(${structure_type}, "B-90"), "36 or something ft 7 in", etc)))

This would technically be more correct.  

You could also try wrapping it all in a concat() but this may not work and give true/false since the way you wrote it that is what you are asking for.

Hope that helps.

View solution in original post

0 Kudos
1 Reply
DougBrowning
MVP Esteemed Contributor

I have seen this posted.  It has to do with the calc having or in it - the app will auto concat all of these but the web will not.

All you results are the same so not sure what you want here.  Your statement is not written correctly either way really.  The app just let you cheat it.

If they are all the same result text then it should be written like

if(selected(${structure_type}, "B-85") or selected(${structure_type}, "B-85OP") or selected(${structure_type}, "B-90"), "34 ft 7 in", "")

If the values are diff you would use nested if statements.

if(selected(${structure_type}, "B-85"), "34 ft 7 in", if(selected(${structure_type}, "B-85OP"), "35 or something ft 7 in", if(selected(${structure_type}, "B-90"), "36 or something ft 7 in", etc)))

This would technically be more correct.  

You could also try wrapping it all in a concat() but this may not work and give true/false since the way you wrote it that is what you are asking for.

Hope that helps.

0 Kudos