Skip to main content

Filter and Analysis 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.

Analysis Axis Expressions

Axis Expressions specify axes for tables and charts when analysing the survey data.

Table of axis operators for use with axis expressions:

OperatorDescription
&
AND
This is often used to compare responses to related questions posed at different stages of the questionnaire. For example, you can analyse consistent responses from the same question asked at the start and end of the questionnaire.
If there are no corresponding codes the result is No Reply . If the operation is unsuccessful or either operand was an Error then the result will be an Error.
|
OR
This is used to analyse responses where one or more questions were answered. For example, when analysing unprompted/prompted awareness questions, you can obtain the net effect of total awareness.
If there are no corresponding codes the result is No Reply . If the operation is unsuccessful or either operand was an Error then the result will be an Error.
:
WITH
The WITH operator is useful for building a complex column definition to analyse multiple attributes of a respondent on one crosstabulation. For example; specifying the columns of a crosstabulation as age range with sex.
If both operands were No Reply or Not Asked then the result will be No Reply . If the operation is unsuccessful or if either operand was an Error then the result will be an Error.
%
PER 
This generates a table of all combinations of the variables.
If both operands were No Reply or Not Asked then the result will be No Reply . If the operation is unsuccessful or if either operand was an Error then the result will be an Error.
!
NOT
This is used to analyse responses where the respondent has not selected a specific response.
If both operands were No Reply or Not Asked then the result will be No Reply . If the operation is unsuccessful or if either operand was an Error then the result will be an Error.
Contents