If Calculation

I am building a data collection form and have tried to create an “If” calculation, please see the provided statement;
If (${Wall_Element}=“Extension 1”,${Wall_Height}*${Wall_Width}-${Wall_Openings},0)

I have added this to a repeating section and whilst the preview seems to accept it and allow me to try the form if I try and deploy the updated version it gives me an error message and will not allow the deployment of the form.
The “Extension 1” is a choice within a single choice option field and as mentioned, I am trying to add this to a repeating section, I would appreciate any guidance, many thanks for any help.

Hi @datacollector,

A variable typically is not allowed with a space in it. But it seems that you have tried to use a space for Extension 1. Would you mind checking it again. It should either be Extension_1 or Extension1 etc.

To learn more on advanced calculations like if-statement please feel free to have a look at our support article ADVANCED USE OF CALCULATE QUESTIONS.

You could also have a look at some workarounds discussed in the forum on if-statement here.

Have a great day!

Hello, I hope you are well, thank you for answering my query, I have made the changes as suggested, unfortunately, I still get an Error and cannot deploy the form. I have copied the error message below;

Error Message

"unable to deploy

your form cannot be deployed because it contains errors:

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

I hope this provides a clue as to what I am doing wrong!

Thank you again for your help.

Hi @datacollector,

Would you mind sharing your xlsform with the community? Maybe the community could have a look at it.

Have a great day!

Hello @datacollector,
It seems you write If (capital) instead of if

I tried your example with if. And all works well.
Extension01.xlsx (14.4 KB)


Hello, thank you for taking the time to look at my form, you are right, I had used capital “I” in “if”, I changed it to lower case as you suggest and it re-deploys as it should, Thank you for pointing this out to me, - I knew it would have been something I had done, usually is - :slight_smile: Thank you to all for the help gratefully received, have a nice day!