# Compound Logic in Relevance Conditions

I have 4 variables/questions of type integer in my .xlsx file. Let's call the variables A, B, C, D. I use XLSForm then upload the form to ODKAggregate.

I am trying to use relevance conditions to display a question only if A=B and also C=D. I have tried all of the approaches below but all of them have produced results that are equivalent to A=B or C=D. In other words, while I want to see the question only if both conditions are met, I am seeing the question if EITHER condition is met. This is equivalent to providing the Boolean OR rather than the Boolea AND.

1: \${A}= \${B} and \${C} = \${D}
2: (\${A}= \${B} and \${C} = \${D})
3: (\${A} = \${B}) and (\${C} = \${D})

To re-articulate, I am using the below as a relevance criterion where I
have integer variables named A, B, C, and D. I want to see the question for
variable E in all cases EXCEPT where A = B and C = D, i.e. when A=B and
C=D, I do not want to see E. I am using 'and' with two NOT EQUAL statements
but none of the below 5 solutions (expanded since last message) works.
Instead all of the below solutions omit E in ANY case where A!=B, rather
than only in the case when A!=B AND C!=D.

1: \${A} != \${B} and \${C} != \${D}
2: (\${A} != \${B} and \${C} != \${D})
3: (\${A} != \${B}) and (\${C} != \${D})
4: (\${A} != \${B} and \${C} != \${D})
5: ((\${A} != \${B}) and (\${C} != \${D}))

··· On Monday, January 23, 2017 at 10:42:48 PM UTC-5, Brett Gall wrote:

I have 4 variables/questions of type integer in my .xlsx file. Let's call
the variables A, B, C, D. I use XLSForm then upload the form to
ODKAggregate.

I am trying to use relevance conditions to display a question only if A=B
and also C=D. I have tried all of the approaches below but all of them have
produced results that are equivalent to A=B or C=D. In other words, while I
want to see the question only if both conditions are met, I am seeing the
question if EITHER condition is met. This is equivalent to providing the
Boolean OR rather than the Boolea AND.

1: \${A}= \${B} and \${C} = \${D}
2: (\${A}= \${B} and \${C} = \${D})
3: (\${A} = \${B}) and (\${C} = \${D})

I found a solution via the use of not(). Why this works and != doesn't is a
mystery. The below evaluates the whole compound logic rather than the first
term of the formula:

not(\${A} = \${B} and \${C} = \${D})

··· On Wednesday, January 25, 2017 at 4:49:00 PM UTC-5, Brett Gall wrote:

To re-articulate, I am using the below as a relevance criterion where I
have integer variables named A, B, C, and D. I want to see the question for
variable E in all cases EXCEPT where A = B and C = D, i.e. when A=B and
C=D, I do not want to see E. I am using 'and' with two NOT EQUAL statements
but none of the below 5 solutions (expanded since last message) works.
Instead all of the below solutions omit E in ANY case where A!=B, rather
than only in the case when A!=B AND C!=D.

1: \${A} != \${B} and \${C} != \${D}
2: (\${A} != \${B} and \${C} != \${D})
3: (\${A} != \${B}) and (\${C} != \${D})
4: (\${A} != \${B} and \${C} != \${D})
5: ((\${A} != \${B}) and (\${C} != \${D}))

On Monday, January 23, 2017 at 10:42:48 PM UTC-5, Brett Gall wrote:

I have 4 variables/questions of type integer in my .xlsx file. Let's call
the variables A, B, C, D. I use XLSForm then upload the form to
ODKAggregate.

I am trying to use relevance conditions to display a question only if A=B
and also C=D. I have tried all of the approaches below but all of them have
produced results that are equivalent to A=B or C=D. In other words, while I
want to see the question only if both conditions are met, I am seeing the
question if EITHER condition is met. This is equivalent to providing the
Boolean OR rather than the Boolea AND.

1: \${A}= \${B} and \${C} = \${D}
2: (\${A}= \${B} and \${C} = \${D})
3: (\${A} = \${B}) and (\${C} = \${D})

Hi Brett,

The behavior you are describing is not what i would expect. Are you (or do
you need to be) accounting for nulls in this situation? Often times,
especially with non-equality checks, you need to account for the null as
well. So maybe something like:

\${A} != \${B} and \${A} != null and \${B} != null

or something like that.

Otherwise I'd review the data output on the other side of test entry and
see if \${A} and \${B} are actually ending up with the values you think they
are.

Also please note, if they are within a repeat then these checks need to be
formulated a different way. The standard \${} reference format is not valid
for referencing items within repeats (neither from within the repeat nor
from outside of it).

Jason

··· On Wednesday, January 25, 2017 at 5:36:28 PM UTC-5, Brett Gall wrote: > > I found a solution via the use of not(). Why this works and != doesn't is > a mystery. The below evaluates the whole compound logic rather than the > first term of the formula: > > not(\${A} = \${B} and \${C} = \${D}) > > On Wednesday, January 25, 2017 at 4:49:00 PM UTC-5, Brett Gall wrote: > >> To re-articulate, I am using the below as a relevance criterion where I >> have integer variables named A, B, C, and D. I want to see the question for >> variable E in all cases EXCEPT where A = B and C = D, i.e. when A=B and >> C=D, I do not want to see E. I am using 'and' with two NOT EQUAL statements >> but none of the below 5 solutions (expanded since last message) works. >> Instead all of the below solutions omit E in ANY case where A!=B, rather >> than only in the case when A!=B AND C!=D. >> >> 1: \${A} != \${B} and \${C} != \${D} >> 2: (\${A} != \${B} and \${C} != \${D}) >> 3: (\${A} != \${B}) and (\${C} != \${D}) >> 4: (\${A} != \${B} and \${C} != \${D}) >> 5: ((\${A} != \${B}) and (\${C} != \${D})) >> >> >> >> On Monday, January 23, 2017 at 10:42:48 PM UTC-5, Brett Gall wrote: >> >>> I have 4 variables/questions of type integer in my .xlsx file. Let's >>> call the variables A, B, C, D. I use XLSForm then upload the form to >>> ODKAggregate. >>> >>> I am trying to use relevance conditions to display a question only if >>> A=B and also C=D. I have tried all of the approaches below but all of them >>> have produced results that are equivalent to A=B or C=D. In other words, >>> while I want to see the question only if both conditions are met, I am >>> seeing the question if EITHER condition is met. This is equivalent to >>> providing the Boolean OR rather than the Boolea AND. >>> >>> 1: \${A}= \${B} and \${C} = \${D} >>> 2: (\${A}= \${B} and \${C} = \${D}) >>> 3: (\${A} = \${B}) and (\${C} = \${D}) >>> >>> >>>