I am trying to do an if statement in a calculate field in Survey123 Connect but I keep getting the error "Syntax Error: Expected token ';'
Does anyone have any ideas what I am doing wrong?
My survey has the following parameters:
QA field type: text
QB field type: text
Q1 field type: select yes_no
Q2 field type: text
Q2 calculation column entry: if(${Q1} = 'yes', ${QA}, ${QB})
I want the answer to Q2 to equal QA if Q1 = yes, and to equal QB if Q1 = no.
Anyone else have experience with this syntax error? I also get the syntax error if I try and replace ${QA} and ${QB} in the calculation field with integers.
Thanks,
Blythe
Solved! Go to Solution.
Hi Blythe,
The calculation syntax that you entered looks correct, but it may be due to spacing of some sort. Please take a look at the attached example to compare to yours. If it does not help, please attach your XLSForm to this thread.
Best,
Brandon
Thank you Brandon, you were right! It was my spacing that was giving me problems. I had a space in between "if" and the first parenthesis.
Thanks again!
Blythe