Nested IF statement in XLSForm

1415
1
10-01-2019 11:06 AM
Miguel-Fernandez
Occasional Contributor

Good afternoon,

I am struggling with creating a nested if statement in the XLSForm for Survey123 Connect. I have a select multiple question that I am trying to count the number of times a selection is made. This is done through a hidden question type with a formula. For example, I have options in the select multiple list for Route 1 EB, Route 1 WB, Route 2 EB, Route 2 WB. Then in a dashboard I have a serial chart with counts for Route 1 and Route 2, etc.  I am wanting the counts for Route 1 EB, WB, etc to be added in the hidden question total_route_1. In the survey, Route 1 EB could be selected, Route 1 WB could be selected, or both could be selected. This is the formula I have written and I can't seem to get it to work.

if(selected(${routes},'route_1_EAST') and not(selected(${routes},'route_1_WEST'),1, or (selected(${routes},'route_1_WEST') and not(selected(${routes},'route_1_EAST'),1, or (selected(${routes},'route_1_EAST') and selected(${routes},'route_1_WEST'),2,0))))

Any help would be appreciated.

Thanks,

Miguel Fernandez

Miguel Fernandez
0 Kudos
1 Reply
DougBrowning
MVP Esteemed Contributor

You need to use the if part each time.  You cannot just give more conditions.

So need to do this
If(condition, yes, if(condition, yes, no))

0 Kudos