Using the relevant column when "not" selecting

I have another qualm. I am trying to use this statement to avoid responding to a question already asked. Question 2 in the “livestock” group should not be repeated if attempted in the “dryland” group

((${select_survey} != ‘dryland’ and ${select_survey} = ‘livestock’) or (${select_survey} != ‘dryland’))

Check cell J13 on the Excel form, been trying to avoid having to repeat the same question. Where am I going wrong?Outcomes_Test.xlsx (27.7 KB)

This is logically only ever true if ${select_survey} = ‘livestock’; that is, the ${select_survey} != ‘dryland’ component is completely redundant. So your expression reduces to:

((${select_survey} != ‘dryland’ and ${select_survey} = ‘livestock’) or (${select_survey} != ‘dryland’))

in which, similarly, the ${select_survey} = ‘livestock’ component is effectively redundant. So your whole expression reduces to:

${select_survey} != ‘dryland’

which, presumably, is not what you intended… :wink:

1 Like

Thanks @Xiphware

I had earlier on tried that but it doesn’t seem to work. I am still being prompted to respond to the similar question the second time around.

Looking at your form, your ${select_survey} question is actually a select_multiple. You cannot, in general, test the value of a select_multiple response with ‘=’, because it could contain multiple results (whereas ‘=’ does a strict, solitary, value comparison). Instead, you need to check whether a specific choice has been selected using the selected() function.

I think you probably need to redo all the relevant expressions in your form to correctly handle checking for a specific choice value in a select_multiple result by using selected() instead of a simple ‘=’

1 Like

Can you please describe, in words, under what conditions do you want to display the “Q2a Do you have access to an irrigation or garden plot?” Its not quite clear from the previous questions in your form… That will help determine what the relevant condition has to be.

Also, I note that Q2b is only relevant if Q2a is Yes, which means it wont be shown if Q2a is hidden, which means you’ll end up with the enclosing group Livestock_Grp would end up having no relevant questions (!).

Also, you have:

begin_group LivestockTool_grp
...
begin_group Livestock_grp
...
end_group LivestockTool_grp

That is, you have an un-terminated group!

Also, you have the initial group master_grp as a field-list, but it only contains a single question, so the field-list is rather redundant.

I’d probably suggest fixing the overall logic of your form first, then worry about sorting out relevance.

**The question is ** “Q2a Do you have access to an irrigation or garden plot?”

Condition 1: If the Dryland Group is selected, the question should only be attempted once even if the Livestock group is selected.

Condition 2: The same question can only be attempted in the Livestock group only if dryland group is not selected

I have sorted out the overall logic and removed the field list.

Outcomes_Test.xlsx (28.2 KB)

1 Like

I think something is getting lost in translation here… Its probably simplest, and unambiguous, to just define the actual truth table that you want here:

dryland selected?      livestock selected?     show Q2a?
--------------------+-----------------------+-----------
     Yes                         No               ?
     Yes                         Yes              ?
     No                          No               ?
     No                          Yes              ?

Once you define the truth table, the correct logical expression for it follows.

2 Likes