Combining expressions
You can combine two or more simple expressions to form a more complex expression that tests the answers to two questions, or performs a more detailed test on the responses to a single question. The operators that you use for combining expressions are as follows:
Expression

Description

And

Tests whether both expressions are True

Or

Tests whether at least one expression is True

Xor

Tests whether one expression or the other is True

Both expressions true
When your test uses two expressions that must both be True, combine them using the And operator:
Expression1 And Expression2
For example:
Sports.ContainsAny({Swimming, Running}) And
DaysVisit.ContainsAll({Saturday, Sunday})
This expression is True when Sport contains one or both of Swimming and Running, and Days contains both Saturday and Sunday. In other words, it is True for respondents who go swimming, running, or both on Saturdays and Sundays. It is False for people who swim and/or run but not on both days, and for people who do neither sport.
At least one expression true
To test whether one expression or the other, or both expressions are True, use the Or operator:
Expression1 Or Expression2
This is a particularly useful operator for using with product or brand awareness studies where you want to test whether a key brand or product was mentioned at one or more of a number of questions. In the following example, the expression is True if the respondent mentioned Hot and Spicy sauce at either the Spontaneous or Prompted awareness question:
Spontaneous >= {HotAndSpicy} Or Prompted >= {HotAndSpicy}
In this example it is impossible for respondents to mention the same response at both questions, but this does not affect the validity of the test. Here is a variation that tests which products the respondent has seen or heard advertised:
AdvertsSeen >= {HotAndSpicy} Or AdvertsHeard >= {HotAndSpicy}
The expression is True for anyone who saw advertising for Hot and Spicy sauce, for anyone who heard advertising for Hot and Spicy sauce, and for anyone who saw and heard this advertising. It is False only for people who did not see or hear advertising for the product.
Only one expression true
The Xor operator combines expressions such that only one of the expressions must be True. If both expressions are True then the expression as a whole is False:
Expression1 Xor Expression2
The following expression is True for anyone who has either children or pets but not both:
HasChildren = {Yes} Xor HasPets = {Yes}
Combining more than two expressions
When an expression contains more than one operator, the expression is evaluated using the following order of precedence:
1 Not
2 *, /, Mod
3 +, −, Like
4 =, <>, <, >, <=, >=
5 And, Or, Xor
If the expression contains two or more operators at the same level they are evaluated in the order they appear in the expression. To impose your own evaluation order, or simply to make it visually clearer how the expression will be evaluated, use parentheses to group the expressions that are to be evaluated together. For example:
Gender = {Male} Or Age >= 21 And Age <= 24
By default, this expression is evaluated from left to right, so it behaves as if there were parentheses around the first two expressions:
(Gender = {Male} Or Age >= 21) And Age <= 24
It is True for anyone aged 21 to 24 and for men who are younger than 24 years of age. In comparison, the expression:
Gender = {Male} Or (Age >= 21 And Age <= 24)
is True for all men and for anyone who is between 21 and 24 years of age.
Here are some more examples, this time using three different questions:
Without any parentheses, the test:
unaid >= {BrandA} Or aided >= {BrandB} And advert >= {BrandB}
follows the standard rules for precedence; that is, from left to right. The expression as a whole is True if the respondent:
▪mentions Brand A at the unaided awareness question and remembers seeing the advertisement for Brand B, or
▪is aware of Brand B when prompted and remembers seeing the advertisement for it, or
▪mentions Brand A at the unaided awareness question, is aware of Brand B when prompted, and remembers seeing advertising for Brand B
Notice here that respondents must always remember the advertisement if the expression is to be true.
If you want the And operator to be evaluated first, you must enclose the two expressions on either side of it in parentheses:
unaid >= {BrandA} Or (aided >= {BrandB} And advert >= {BrandB})
Now the expression as a whole will be true if the respondent:
▪mentions Brand A unaided, or
▪is aware of Brand B when prompted and remembers seeing advertising for it, or
▪belongs in both the previous categories
This example removes the previous requirement for respondents who are aware of Brand A to have seen Brand B advertised.
See also