b'ODK Validate Errors: Invalid calculate for the bind attachment t

1834
3
Jump to solution
02-04-2022 09:42 AM
AlleePrusia
Emerging Contributor

Hi,

I am quite the novice when it comes to survey123. I am trying to generate a form that will out put a calculated value from our survey questions. I am using the if(${NAME}='NAME'='0', formula.

I am trying to get the form to generate a score from the values selected in the survey. Here is what I have so far. If someone could help me with the equation that will calculate the values in the score column that would be awesome! 

The error message I have is b'ODK Validate Errors:\n>>XForm is invalid. See above for the errors.\norg.javarosa.xform.parse.XFormParseException: Invalid calculate for the bind attached to"${score}" : Couldn\'t understand the expression starting at this point ...test/wetplants\xcd\x8e\'))))))))))))))

Thanks!

I have attached the form I have right now. 

0 Kudos
1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

To add more to @DougBrowning 's answer, here is a simple XLSForm that hopefully gives you some ideas.

Note that:

  • When you create a list, you can assign a number to the value of a choice. For example: In the grade choice list, the value of the label Absent can be set to 0. In this way, when the user selects Absent, the value of the question is set to 0.
  • If you do the above, you may want to set the bind::esri:fieldType column to esriFieldTypeSingle. In this way, the selections of your choice list will be stored as a number in ArcGIS
  • You can then use a calculation to get the score.
    • ${channel} + ${thalweg} : This is the simplest syntax, but will return a null value if any of the input values is null. This is because: 1 + 0 = 1 but 1 + null = null    If you use this syntax, you will want to make sure all your input questions are required
    • coalesce(${channel},0) + coalesce(${thalweg},0) is safer. The coalesce function takes two values and returns the first value that is not null.  With this, your sum will get you back a number even if one the questions has not been answered.

Check the attached XLSFile for details

 

Score.gif

 

View solution in original post

3 Replies
DougBrowning
MVP Esteemed Contributor

You are missing the final else on all your if statements.

Like if({channel}='something','3', ELSE)  need at least something there.  Also not sure why you are making them all string vs number depends on your use.

See https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformformulas.htm 

Hope that helps.

IsmaelChivite
Esri Notable Contributor

To add more to @DougBrowning 's answer, here is a simple XLSForm that hopefully gives you some ideas.

Note that:

  • When you create a list, you can assign a number to the value of a choice. For example: In the grade choice list, the value of the label Absent can be set to 0. In this way, when the user selects Absent, the value of the question is set to 0.
  • If you do the above, you may want to set the bind::esri:fieldType column to esriFieldTypeSingle. In this way, the selections of your choice list will be stored as a number in ArcGIS
  • You can then use a calculation to get the score.
    • ${channel} + ${thalweg} : This is the simplest syntax, but will return a null value if any of the input values is null. This is because: 1 + 0 = 1 but 1 + null = null    If you use this syntax, you will want to make sure all your input questions are required
    • coalesce(${channel},0) + coalesce(${thalweg},0) is safer. The coalesce function takes two values and returns the first value that is not null.  With this, your sum will get you back a number even if one the questions has not been answered.

Check the attached XLSFile for details

 

Score.gif

 

AlleePrusia
Emerging Contributor

Thank you! This was very helpful!

0 Kudos