Nested If/Then statement error in Survey123

201
2
Jump to solution
12-13-2021 10:34 AM
EileenWeppner
New Contributor

Hello All,

I am working in Survey123 and I need some help with an If/Then statement. I am getting the following error when trying to convert the XLSForm:

B”ODK Validate Errors:\n>>Something broke the parser. See above for a hint.\nError evaluating field ‘leftcbavgheightnum’: The problem was located in calculate expression for ${leftcbavgheightnum}\nXPath evaluation: cannot handle function ‘If’\nCaused by: org.javarosa.xpath.XPathUnhandledException: The problem was located in calculate expression for ${leftcbavgheightnum}\nXPath evaluation: cannot handle function ‘If’\n\t… 10 more\n\nResult: Invalid”

Here is the calculation (If/Then statement) I wrote:

If(selected(${leftcutbankheight},'0'),0,If(selected(${leftcutbankheight},'<5'),2.5,If(selected(${leftcutbankheight},'6-10'),8,If(selected(${leftcutbankheight},'11-25'),18,If(selected(${leftcutbankheight},'>25'),25,0)))))

{leftcutbankheight} is a select one/text field

The result of the If/Then statement is a numeric decimal field ({leftcbavgheightnum}).

I am pretty new at Survey123. Any help would be much appreciated!

Thanks!

Eileen

1 Solution

Accepted Solutions
DougBrowning
MVP Notable Contributor

My first guess is if should be lowercase.  So if not If.  It almost seems like that is what the error is saying.

The second guess is it thinks <5 is HTML.

Try that.  Hope it works.

View solution in original post

2 Replies
DougBrowning
MVP Notable Contributor

My first guess is if should be lowercase.  So if not If.  It almost seems like that is what the error is saying.

The second guess is it thinks <5 is HTML.

Try that.  Hope it works.

EileenWeppner
New Contributor

That was it!!

Yes, the problems were "If," "<," ">," and "-" ....changed to "if," "less," "grt," and "to"

Thank you so much!!