Custom logic using or if & and if statements

Hi – I am trying to write a conditional formula that would have the survey skip a question if the response to one question is ‘a’ or ‘b’ (sample responses) and if the response to another question is ‘a.’

I’ve tried a few different iterations of the formula, but I can’t get it to work:
if \${_18_Did_you_use_the_Alumni_TIE} = ‘no’ or \${_18_Did_you_use_the_Alumni_TIE} = ‘i_don_t_know_what_this_is’ and if \${_20_Project_lead_team_member} = ‘no’

You cannot combine “and” with “or” directly on the same level, e.g. if( … and … or …, …, …). You need to separate “or” from “and” expressions with brackets, e.g. if( (… and …) or … or …, …, …).

@Kal_Lam. Might be good to explain this also in the Help Center article, please.

1 Like

@sgates3, maybe list your two dummy questions along with their choices and share the conditions for the skips. The community should be able to guide you accordingly!

Hi @wroos! Thanks so much for weighing in. I was trying to figure out the bracketing (and commas), and I got errors with all the iterations I tried.

So the below formula worked (without any of the ifs) if the respondent answered “I don’t know what this is,” and “no” to Question 20. It did not work if the respondent answered “no” to Question 18 (presumably because of the bracketing issue) and “no” to Question 20.

\${_18_Did_you_use_the_Alumni_TIE} = ‘no’ or \${_18_Did_you_use_the_Alumni_TIE} = ‘i_don_t_know_what_this_is’ and \${_20_Project_lead_team_member} = ‘no’

Here is my attempt at bracketing:
((\${_18_Did_you_use_the_Alumni_TIE} = ‘no’), or (\${_18_Did_you_use_the_Alumni_TIE} = ‘i_don_t_know_what_this_is’)), and (\${_20_Project_lead_team_member} = ‘no’)

Do you know where I am making the error?

Also, I am trying to write the code by mimicking others’ formulas. Is there a good help article on this particular issue, or, better yet, a guidebook on using XLSForm (if that’s correct) code? Still new to a lot of this, thanks for your patience :).

Good question @Kal_Lam, thanks for asking. Please me know if the below information is sufficient, if you have a moment.

1. Did you use the Alumni TIES Online Course on Small Grants Management?
a) Yes
b) No
c) I don’t know what this is

2. Were you a project lead or a team member on a proposal/application for an Alumni TIES Small Grant?
a) Yes, I was a project lead on a proposal/application for an Alumni TIES Small Grant.
b) Yes, I was a team member on a proposal/application for an Alumni TIES Small Grant.
c) No

I want the survey to display Question 21 only if respondents answer a OR b to Question 18 AND c to Question 20. (Not sure that this is relevant but respondents only get Question 19 if they answer Yes to Question 18; that’s working fine).

Did you try this logic in Q21?
(\${Q18}=‘a’ or \${Q18}=‘b’) and \${Q19}=‘c’
AndifOr.xlsx (12.8 KB)

1 Like