Constraint - values entered in 3 questions must = 100

Hi Folks,

I am designing a form where 3 questions must be answered with a value (percentage). I would like to set a constraint, so that the sum of these 3 answers must equal 100. I cannot find anything in the forum topics to help me do this. Is this possible?

Thank you,
Tania

1 Like

Hi @taniak,

What are the type of your questions?

I believe we can do something with calculations.

@taniak, this post discussed previously should help you solve your issue:

1 Like

@Kal_Lam @hakan_cetinkaya, Thank you both - I failed to find this particular post.

1 Like

@Kal_Lam @hakan_cetinkaya , I seem to have run into a problem. I have used the example to create a test version, but it seems not to work when I check the form out in Preview, and I cannot even deploy the form. Have I somehow made an error in my syntax?

I have attached my xls file and a screenshot of what happens when I have deliberately made an incorrect entry that I subsequently correct.

BBCH Test.xlsx (10.2 KB)

Thanks for your help.
Tania

@taniak, have you played around with this XLSForm to understand how it works?

@taniak, the problem was with your expression here:
${bbch_percent_ave}!=" and ${bbch_percent_lo}!=" and ${bbch_percent_hi}!=" and ${bbch_calc}!=100 where you have used " instead of ' '.

Here is your refined XLSForm:

BBCH Test.xlsx (9.4 KB)

@Kal_Lam , Ouf, I did not notice the difference in this syntax. Even when I had your version and my version open together, it was only by backspacing over the characters that I realised you had 2x ’ and I had 1x "! I figured it was my syntax, but I couldn’t spot the difference visually, even when I zoomed in. So that it is clear to me next time I need to repeat this, I have put a space in between the the 2 ’ marks (’ '), so it is obvious that they are single quotes. I have tested this, and it works - perhaps it would be worth updating the hundred percent xlsx sheet to make it obvious to the next folk who want to do this? Or, perhaps I should have just copied from here & pasted into mine, and then changed the question names… Anyhow, very many thanks. Tania

1 Like

@taniak, :clap: :heart: :partying_face: