Auto Calculation works in Connect but not in Web Form

322
2
07-16-2022 09:03 AM
tigerwoulds
Occasional Contributor III

I have a simple formula set up in Survey123 Connect that auto-calculates a Text value based on a selected value from a previous question.

This works correctly in the Connect app, but when I publish to my Portal and open the Web Form, the auto-calculation is broken and only returns True or False. 

if(selected(${installation}, 'Fort A'), 'User A', '') or if(selected(${installation}, 'Fort B'), 'User B', '') or if(selected(${installation}, 'Fort C'), 'User C', '')

Can anyone take a look at my formula and point me in the right direction? Thanks!

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

In Survey123, operators like or or and are really meant to be used in statements that can evaluate to true or false. Frankly, I'm surprised that the formula actually works in Connect.

To use a series of separate conditions, you actually have to nest them so that if your "Fort A" check fails, it will then check for "Fort B", and so on. Written out, that would look like this:

if(selected(${installation}, 'Fort A'), 'User A', if(selected(${installation}, 'Fort B'), 'User B', if(selected(${installation}, 'Fort C'), 'User C', '')))

 But honestly, it seems more like you're just replacing "Fort" with "User". If these are both string fields, you could try something like this instead:

concat('User', substr(${installation}, 4, 0))

That way even if the Fort choices expand to larger numbers, it will still work.

jcarlson_0-1657995639306.png

 

- Josh Carlson
Kendall County GIS
0 Kudos
tigerwoulds
Occasional Contributor III

Thanks, Josh. I see what you're saying about the nested conditions and will try that. I did skew the Fort and User names a bit for anonymity, they are not actually similar at all so your second suggestion will not work for me.

I did figure out a solution using a linked CSV table that works quite nicely. I uploaded a CSV table to my portal which acts like a lookup table. This elimates the need for nested formulas and makes it easier to manage over time. 

Work with CSV data in ArcGIS Survey123 - Esri Community

0 Kudos