Calculation Question type error report

Hello, Trying to deploy my survey form, I faced some error messages when using the calculation question type. It seems that the question type in my form crashed with something. I tried to figure out what the problems are by searching keywords on the Kobo community. But I still have been struggling with the issue. Why couldn’t it demonstrate the advanced calculate function such as if statements or sum when others work well?


Here is my form showing the errors.
error2.xlsx (7.6 KB)

Oh, plus, I took another approach to resolve the problem by uploading xlsform with including the calculation functions, yet it arose another issue.


error1-2

Below was the xlsform I uploaded
error1.xlsx (11.3 KB)

Your comments would be so helpful to help me find out my mistake.
Thank you

Welcome to the community @jessiemj! The issue you are facing is as follows:

If you look at the survey tab of your xlsform you will see wm5fd26 in A4, dd9hq57 in A5 and so on (as shown in the image below) …


However, if you look at the choices tab you will not see the same under the list_name. You will see I1, Q2 and so on (as shown in the image below) …

So the first change you need to make is to rename the same with I1 in A4, Q2 in A5 and so on (as shown in the image below) …

I also made some slight edits in the calculation column like IF to if and SUM to coalesce(${C3},0) + coalesce(${C4},0) + coalesce(${C5},0) as outlined in the image below:

Making all these changes, your xlsform now works smoothly:

Reference edited xlsform:

error1.xlsx (13.2 KB)

Note: You could always validate your xlsform with this online validator to see if your xlsform has any syntax errors.

1 Like

Hello @jessiemj,
Your problem was if and sum need to be in small letter. KoBo is mostly casesensitiv. functions, expression syntax etc. only in small letters. Of course, you are free for Capitals in names and labels, but names need to be unique independent of capitals.

2 Likes

My goodness, how fast!
Your solution works so well. Thanks for your helping.

I want to say all my problem has gone now, but I encountered another obstacle.
What I plan for my form is showing the score of the household hunger scale.
Previewing the sample, I realized that I missed counting the score 0 when the respondent answered No to hunger.
So I put other calculation question types so that it can include all scores without missing 0 points.
But then the error report popped up as below:

I looked up my xlsform, yet couldn’t find suspected issues.

My A column seems to have no problem that I had before.
Could you help me see what issues occur on my form?

Here is my updated form.
error3.xlsx (7.9 KB)

Besides, just one tiny question, is there any reason that you used the coalesce function rather than using sum? I have no idea that kind of function exists at all. I read the manual pages (https://support.kobotoolbox.org/advanced_calculate.html) but couldn’t find such a command.
Is there any page that demonstrates the advanced command like coalesce? If you let me know where it is, it would be helpful. Thanks for your devotion.

Hi @jessiemj,

You should be able to learn more about coalesce here.

1 Like