Getting error in form on ODK Collect within a field that uses calculate

I suspect as I'm new to this I'm just doing something wrong in the setup

1. What is the problem? Be very detailed.

I'm trying to create a form (using ODK Build) that calculates a sum total using the values from other fields so specifically
1 field is a number (integer) with a data name of r1
Another is a number (integer) with a data name of r1
The third is the total field and I have tried putting ${r1} + ${r2} into the "calculate" property of that field

All of the fields are in a group

I get an XForm parse exception stating it doesn't understand the expression

2. What app or server are you using and on what device and operating system? Include version numbers.

Running on Huawei P20 Pro Android 9

I export xml file from ODK Build and put it in google drive and then "Get Blank Form" from Google drive via the app. The loading works fine and forms work when I don't use variable references in the calculate property

3. What you have you tried to fix the problem?

Tried adding and removing spaces around the variables
Moved the fields outside the group
Tried just adding ${r1} into the calculate field

Note: I've added the function now() into another date field (inside the calculate property) and this works ok

Seems to be having issues referencing variables

4. What steps can we take to reproduce the problem?

Just create a simple form with 3 integer fields

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.

Hi @John_Zurowski
welcome to the forum! Please introduce yourself here!

could you attach your form? otherwise it's difficult to tell what's wrong.

Here's a simple form that hopefully illustrates the problem
running ODK Collect v1.27.3 and using online version of ODK Build

CalcForm.xml (1.4 KB)

Ok now it's clear...
question names with dollar signs and curly baskets we use in xls forms if you edit xml file what BTW is not a good practice you need something like calculate="/data/n1 + /data/n2".
Fixed version:
CalcForm.xml (1.4 KB)

ohh probably you didn't edit xml file but just added it in ODK Build so it's not your fault it might be a bit misleading. I would rather recommend creating forms in xls or starting with ODK Build and then adding more complex stuff after exporting your form to xls.

Hi Grzesiek

That worked - I've just started using ODK today so on a steep learning curve and ODK Build is a bit more intuitive for now

Dzieki as they say in Poland

I see totally. It's a good first step but keep in mind that it doesn't provide all possible options especially if you need to add more complex logic. So once you get to know more about it you can review https://xlsform.org/en/ so that you can do the same in excel/google sheets or start with ODK Build then export to xls and continue "manually".

You have polish last name, do you speak polish maybe?

1 Like

Hi Grzesiek

Indeed I speak some Polish (both parents are Polish emigrants) although I was born in the UK

I've moved to using spreadsheet for form creation and editing now that I'm comfortable with the format

Thanks for your help so far

1 Like

A post was split to a new topic: How can I get my unique