Not allowing certain response if a certain response is checked from a previous questions

I am working on a survey in which we ask when was the first time after birth a person started breastfeeding with various time allotments and an option stating they don’t breastfeed. The next question asks “During the first six months of life, what did you give your baby to drink?” One of the options is breastmilk.

I would like to put validation criteria that makes it unable to select “do not breastfeed” from the previous question and “breastmilk” from the next. I have tried with something like this but to no avail:

not(selected(., ‘Breastmil’) and selected(.)${Breastfeeding_began} = ‘no_breastfeedi’)

Please help XLS coders!

Hi

try this :

(selected(${Breastfeeding_began} , ‘no_breastfeedi’) and not(selected(. , ‘Breastmil’))) or (not(selected(${Breastfeeding_began} , ‘no_breastfeedi’)) and selected(. , ‘Breastmil’))

Thanks

Regards
Tulus

Thanks, I think it is on the right path however it makes it so that if I select any response from the “Breastfeeding_began” question it makes it invalid with any response from the next question.

@Anderson if I understand correctly, you would like to limit people from selecting ‘breastmilk’ if they have selected ‘no breastfeeding’ in the previous question. This formula below and the attached XLS file should help.

not(selected(., ‘breastmilk’) and (selected(., ${When_was_the_first_time_after_}, ‘no_breastfeedi’)))

breastfeeding example.xls (27 KB)

You understand correctly I believe. However, I would still like them to be able to select ‘breastmilk’ if they selected another option in the previous question. If you see the uploaded example in which I just uploaded your example it makes it unable to select ‘breastmilk’ no matter what selection was chosen from the previous question.

Thanks so much for your help!

04

Hello everyone,

i tried that out and it seems to works no?
in the constraint:
if(selected(${when_was_the_first_time_after_},‘no_breastfeedi’),not(selected(.,‘breastmilk’)),selected(.,‘breastmilk’))

I share the file, i had to modify some majuscules, i don’t know why but it seems i always have to use miniscules in the name columns…

breastfeeding_example.xls (27.5 KB)

Hope it was useful

Quentin

@Quentin, please try the attached file.

breastfeeding_example.xls (27.5 KB)

Hello,
you may try this example. In addition the second question only comes up after one (and not all) of the options in the first question where selected.
Hope this helps.
Best regardsNotSelected Filter 01.xlsx (11.0 KB)