Hello,
I am trying to write a nested IF statement in Survey123 Connect, and I am having a bit of trouble with the syntax. Here is the gist of what I want to do, in Python syntax:
<SPAN class="keyword token">if</SPAN> val1 <SPAN class="operator token">==</SPAN> <SPAN class="string token">'a'</SPAN> OR val1 <SPAN class="operator token">==</SPAN> <SPAN class="string token">'b'</SPAN><SPAN class="punctuation token">:</SPAN>
score <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Very Low'</SPAN>
<SPAN class="keyword token">elif</SPAN> total_score <SPAN class="operator token"><</SPAN> <SPAN class="number token">10</SPAN><SPAN class="punctuation token">:</SPAN>
score <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Very Low'</SPAN>
<SPAN class="keyword token">elif</SPAN> total_score <SPAN class="operator token"><</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">:</SPAN>
score <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Low'</SPAN>
<SPAN class="keyword token">elif</SPAN> total_score <SPAN class="operator token"><</SPAN> <SPAN class="number token">30</SPAN><SPAN class="punctuation token">:</SPAN>
score <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Moderate'</SPAN>
<SPAN class="keyword token">elif</SPAN> total_score <SPAN class="operator token"><</SPAN> <SPAN class="number token">40</SPAN><SPAN class="punctuation token">:</SPAN>
score <SPAN class="operator token">=</SPAN> <SPAN class="string token">'High'</SPAN>
<SPAN class="keyword token">elif</SPAN> total_score <SPAN class="operator token"><</SPAN> <SPAN class="number token">45</SPAN><SPAN class="punctuation token">:</SPAN>
score <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Very High'</SPAN>
<SPAN class="keyword token">elif</SPAN> total_score <SPAN class="operator token">></SPAN> <SPAN class="number token">45</SPAN><SPAN class="punctuation token">:</SPAN>
score <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Extreme'</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
So far, I've gotten this much to work in Survey 123:
if(selected(${material}, 'a'), 'Very Low',if(selected(${material}, 'b'), 'Very Low', '0'))
I seem to be able to get as far as the first IF statement and then an ELSE statement, but nesting any further is returning error messages like "cannot handle 'if' requires 3 arguments. Only 4 provided."
Any help would be appreciated!! Thanks!
James Tedrick