Error when using and / or for calculated booleans

I made a calculation question called calc3 with
${calc1} or ${calc2}, where calc1 and calc2 can be true or false.

calc3 always returns true, no matter what the input from calc1 and calc2.

Example xlsform to demonstrate:
boolean_error_test.xlsx (5.9 KB)

I get the same behaviour in the kobo toolbox preview and on the kobo collect app.
Can anyone tell me why its happening?

You might have a look here: https://getodk.github.io/xforms-spec/#xpath-functions.

1 Like

Thanks wroos! Copying here in case the link goes down:
a boolean false result, such as from the expression 1 > 2, is stored in the model as the string "false". When referring to that node in another expression as a boolean argument, the string value of that node (“false”) is converted to a boolean by calling the boolean() function which returns the boolean true because boolean("false") = true(). To deal with this, it usually best to not do boolean comparisons with stored values (compare strings instead) or use boolean-from-string() in the XPath comparison expression.

1 Like