My goal is to create an “Additional Cost” field that populates choices from various questions throughout the survey. Basically, a submitter will select question choices and only specific choices will populate in the “Additional Cost” field. I got this to work when I only reference one field in the calculation column. However, there are multiple fields I would like to bring.
The expression below works and the ArcGIS_Developer_Subscription text is placed in the “Additional Cost” field.
However, I cannot find a way to use multiple IF statements. Here are examples of other choices I would like to bring in to the “Additional Cost” field.
Any help would be greatly appreciated and welcomed.
Solved! Go to Solution.
That is how if statements work, once one of the statements evaluate to true, it stops. You likely want to set up multiple temporary fields to do each if statement separately and then combine them into a single field.
You chain them so that the default answer for one is the next if statement...
if(${ent_specialty_lic}='ArcGIS_Developer_Subscription', "ArcGIS_Developer_Subscription", if(${ent_additional_portal_products}='ArcGIS_Insights', "ArcGIS_Insights", if(${singleuse_pro_ext}='ArcGIS_Aviation_Airports_for_Pro', "ArcGIS_Aviation_Airports_for_Pro", " ")))
Thank you for your reply. Your method works when selecting a single choice (select_single) in a question. However I have questions that are multiple choice (select_multiple) and a submitter could pick 2+ choices in the same question. I tried using the selected() function in the expression but Survey123 throws an error when updating the XLS.
Error - Invalid calculate for the bind attached to "$additionalCost"; null in expression...
It is the same basic principle.
if(selected(${ent_specialty_lic}, 'ArcGIS_Developer_Subscription'), 'ArcGIS_Developer_Subscription', if(selected(${ent_additional_portal_products}, 'ArcGIS_Insights'), 'ArcGIS_Insights', if(selected(${singleuse_pro_ext}, 'ArcGIS_Aviation_Airports_for_Pro'), 'ArcGIS_Aviation_Airports_for_Pro', '')))
Your example has If capitalized, which Survey123 is not going to like.
I really appreciate your effort with this issue. I successfully implemented "selected()" to the expression. However I have multi-choice responses for questions. Basically a user can select 2+ answers. When I add the additional response to the expression, only the first response is populated in the field. How can make sure multiple choices are recorded?
Example - there are two potential responses for {singleuse_pro_ext}. One for Aviation and one for Interoperability. Only the Aviation response is populated in the field even though both were picked from the choice list.
I got everything configured using your example. Thank you!