Filter expressions

Filter expressions are logical Boolean expressions. The general format of filter expressions is:

operand operator operand

The operand may be:

  • one or more question variables
  • one or more numbers
  • one or more pieces of text enclosed in quotation marks (This is called a text string)
  • a complete expression enclosed in braces

You may also apply a pattern to the operand, for example, to search for dates within a specific range

You can find out more by watching this video demonstrating how to add expressions.

Comparison operators

The operator must be one of the following:

SymbolTextMeaningFilter_ExampleDescription
=MTmatchQ2=1To select respondents who have given answer 1 to question 2. (If question 2 is a Multiple Response question they may have given other answers as well).
==EQexact matchQ4==1To select respondents who have given only answer 1 to question 4. If question 1 is a Multiple Response question they must have given no other answer in addition to answer 1.
>GTgreater thanQ5 GT 50
Q5>50
To select only respondents who have given a value of greater than 50 at question 5.
>=GEgreater than or equal toQ5 GE 50
Q5>=50
To select only respondents who have given a value of greater than or equal to 50 at question 5.
<LTless thanQ5 LT 50
Q5<50
To select only respondents who have given a value of less than 50 at question 5.
<=LEless than or equal toQ5 LE 50
Q5<=50
To select only respondents who have given a value of less than or equal to 50 at question 5.

Logical operators

Items or expressions may be grouped together using the following operators

,ORor any of the items separated by , or ORQ2=1 OR Q2=2
Q2=1,Q2=2
Q2=(1 OR 2)
Q2=(1,2)
To select only respondents who have given answer 1 or answer 2 to question 2.
~TOor range: any item in the range between the two terms separated by ~ or TOQ2=(1 TO 3)
Q2=(1~3)
To select respondents who have given answers within the range 1 to 3 to question 2. (1 or 2 or 3).
&ANDand: both the terms separated by & or ANDQ2=1 AND Q4=1
Q2=1&Q4=1
To select respondents who have given answer 1 to question 2 and also given answer 1 to question 4.
!NOT or UNLESSnot: all cases not included in the following expressionNOT Q2=1
UNLESS Q2=1
!Q2=1
To select respondents who have not given answer 1 to question 2.

Items may be identified using the following operators

#NUMthe number of replies selected in a multi-response questionsnum Q5>3 To select only respondents who have given more than three answers to question Q5
 CASEthe specified case(s)case >100All cases after the first hundred

Literal expressions

SymbolTextMeaningFilter exampleDescription
=MTmatchQ4a = “pie”Selects all cases where the characters “pie” appear in the text of the data for Q4a. This search is case sensitive.
==EQexact matchQ4a == “pie” Selects all cases where “pie” is the exact text of the data for Q4a
as {pattern name}using a patternQ4a as lower case = “milkshake”Selects all cases where the characters “milkshake” appear in the text for Q4a. The question text is converted to lower case prior to matching. This can be used to find matches entered that include upper or lower case characters, such as “Milkshake”. Other patterns available include upper case, title case and sentence case.
ANDcombine more than one filter where all filters are trueQ4a = “pie” AND Q4a = “milkshake”Selects all cases where Q4a has both the text “pie” and “milkshake” in the response
OR combine more than one filter where at least one filter is true Q4a = “pie” OR Q4a = “milkshake” Selects all cases where Q4a has the text “pie” and/or the text “milkshake” in the response.
!NOT or UNLESSall cases not included in the following expression NOT Q4a = “pie” Selects all cases where the characters “pie” do not appear in the text of the data for Q4a.
OKOKQ1 OKSelects all cases where a valid response has been given for Q1. This filters out any responses where Q1 has no reply or is not asked.
NRNo replyQ1 NR Selects all cases where Q1 has no reply.
NANot askedQ1 NA Selects all cases where Q1 has not been asked.
Contents