If statements and Syntax Error: Expected token ';'

530
2
Jump to solution
09-26-2018 10:21 AM
Highlighted
New Contributor III

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

James Tedrick‌ 

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Esri Regular Contributor

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

View solution in original post

2 Replies
Highlighted
Esri Regular Contributor

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

View solution in original post

Highlighted
New Contributor III

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