Field calculation works in preview mode, but not in the published Survey

157
2
Jump to solution
07-26-2020 11:45 PM
MartinaPuljko
Esri Contributor

Hi everybody,

I'm trying to create a survey in which multiple fields are supposed to populate based on an answer selected in previous fields.

One example is field "points" which is supposed to populate based on the selected answer from a filed "monthly_income".

I've tried to create the following calculation for the field "points":

  • if(selected(${monthly_income}, 'do_2_000_00_kn'), '3','') or if(selected(${monthly_income}, 'od_2_001_00_3_000_00_kn'), '2','') or if(selected(${monthly_income}, 'od_3_001_00_3_500_00_kn'), '1','') or if(selected(${monthly_income}, 'vise_od_3500'), '0','')

After creating the survey, the calculations work in preview mode, but not in the published, online survey.

Any suggestions?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
JamesTedrick
Esri Esteemed Contributor

Hi Martina,

You are using several statements that are joined together with 'or'; this would lead to a Boolean (true/false) calculation.  You should instead use a nested series of if() statements to filter each option:

if(selected(${monthly_income}, 'do_2_000_00_kn'), '3', if(selected(${monthly_income}, 'od_2_001_00_3_000_00_kn'), '2', if(selected(${monthly_income}, 'od_3_001_00_3_500_00_kn'), '1', if(selected(${monthly_income}, 'vise_od_3500'), '0',''))))

View solution in original post

2 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Martina,

You are using several statements that are joined together with 'or'; this would lead to a Boolean (true/false) calculation.  You should instead use a nested series of if() statements to filter each option:

if(selected(${monthly_income}, 'do_2_000_00_kn'), '3', if(selected(${monthly_income}, 'od_2_001_00_3_000_00_kn'), '2', if(selected(${monthly_income}, 'od_3_001_00_3_500_00_kn'), '1', if(selected(${monthly_income}, 'vise_od_3500'), '0',''))))

MartinaPuljko
Esri Contributor

Works perfectly. Thank you!

0 Kudos