Hide field until 5 or more questions have been answered (composite index)

I’m new to kobotool. I’m trying to get responders to grade the severity of 7 symptoms by selecting one of 4 options - none, mild, moderate, severe. The selection returns a numerical value of 0, 1, 2 and 3, respectively. The maximum total severity score is 21 maximum (3 x 7). However, the total severity score is only valid when at least 5 questions have been answered. The preview shows the total score increasing with each question answered but I want it to show only after 5 querstions have been answered. I tried using skip logic but it works if any or all 7 questions are answered. Is there a way to prevent the total severity score from showing until the responder has answered at least 5 of the 7 questions. I’ll be very grateful to anyone who can help.

You can add a calculate line after each question (calc1, calc2 etc), with an if statement:


Then after all the questions, add another calculate line with

calc_total = calc1+calc2+calc3+calc4+calc5+calc6+calc7

and use a relevant column in your total severity score
calc_total >= 5

1 Like

I think in the if expressions there should be no space. So, ‘’ or “”" would make it working. As far as I know those empty values are represented as empty, not as a blank.

1 Like

Could you send us part of your form here, please, for better support.
Also your skip should work, if you integrate the empty value option, for example with coalesce(…).

1 Like

Yes, in my code there is no blank space between the quotes. It seems like that because it’s a monospace font.

If you upload your existing from I can try to add the constraints.

1 Like

I may be doing something wrong because the severity score does not show after I add calc_total >=5 in the relevant column, even after I answer all 7 questions.
Thanks for the offer but I couldn’t upload my form because I’m a new user. This is what I did and hope it was correct - I added calc1+calc2+calc3+calc4+calc5+calc6+calc7 without the $ and curly brackets in the final calculation line. I’ll work on the form another time, Thank you all for your help.

1 Like

For testing/development, you may temporarily set the calculations to integer type. So you can test/SEE how it works. Also, you could add an integer (or text type) with a copy of your relevant clause in calculate column there to SEE what happens for different combinations.
@Kal_Lam may allow upload for you as new user, please.

Hi @fluppy,

You should be able to upload your xlsform. Thank you @wroos and @ks_1 for providing support to @fluppy :clap:

Thank you. This is the file.
I’m new to kobotoolbox so I’m likely to need mor help.
Have a good week.
Severity_scale_V2.xlsx (11.4 KB)

You could do the same as outlined in the image below:

In the survey tab of your xlsform:

In the choices tab of your xlsorm:

Image 2

Data entry screen as seen in Enketo: (when the conditions are not met)

Data entry screen as seen in Enketo: (when the conditions are met)

Reference xlsform:

Severity_scale_V2.xlsx (12.6 KB)

1 Like

Many thanks Kal

1 Like