How to restrict an answer based on a previous response?

Hi all,

I’m currently trying to refine my form through kobo and xls forms.

I have an initial question of How many days in the past week has your household eaten vegetables? The answer can be between 0-7, through a range function

I have a question leading from this, How many days in the past week has your household eaten green leafy vegetables? I want this answer to be restricted to equal or less than the answer for overall vegetables.

Any tips on how to do this? I was thinking of a constraint or if function, but struggling with the right formula

Thanks in advance,
Ben

Hello,

Yes your are right this is the way to do.
Let’s say your first question is ${day_vegetable}, in the second question your can put a constraint using the dot to refer to the actual question. So in the constraint column of your XLS Form, you put without the " :
" .<=${day_vegetable} "
If you are using the form buidler i don’t know i never use it but there is surely a way!

Have fun

1 Like

Hi Quentin,

Wow that worked a treat with your code!

Thanks so much,
Ben

1 Like

Hi, can you do this in the form builder? Or editing the xlsform is the only way? Thank you.

1 Like

Hi @wiydiy, I have always found it easier to do it through excel… Sorry about the delay

1 Like