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:
| Symbol | Text | Meaning | Filter_Example | Description |
|---|---|---|---|---|
| = | MT | match | Q2=1 | To 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). |
| == | EQ | exact match | Q4==1 | To 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. |
| > | GT | greater than | Q5 GT 50 Q5>50 | To select only respondents who have given a value of greater than 50 at question 5. |
| >= | GE | greater than or equal to | Q5 GE 50 Q5>=50 | To select only respondents who have given a value of greater than or equal to 50 at question 5. |
| < | LT | less than | Q5 LT 50 Q5<50 | To select only respondents who have given a value of less than 50 at question 5. |
| <= | LE | less than or equal to | Q5 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
| , | OR | or any of the items separated by , or OR | Q2=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. |
| ~ | TO | or range: any item in the range between the two terms separated by ~ or TO | Q2=(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). |
| & | AND | and: both the terms separated by & or AND | Q2=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 UNLESS | not: all cases not included in the following expression | NOT 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
| # | NUM | the number of replies selected in a multi-response questions | num Q5>3 | To select only respondents who have given more than three answers to question Q5 |
| CASE | the specified case(s) | case >100 | All cases after the first hundred |
Literal expressions
| Symbol | Text | Meaning | Filter example | Description |
| = | MT | match | Q4a = “pie” | Selects all cases where the characters “pie” appear in the text of the data for Q4a. This search is case sensitive. |
| == | EQ | exact match | Q4a == “pie” | Selects all cases where “pie” is the exact text of the data for Q4a |
| as {pattern name} | using a pattern | Q4a 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. | |
| AND | combine more than one filter where all filters are true | Q4a = “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 UNLESS | all 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. |
| OK | OK | Q1 OK | Selects 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. | |
| NR | No reply | Q1 NR | Selects all cases where Q1 has no reply. | |
| NA | Not asked | Q1 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:
| Operator | Description |
|---|---|
| & 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. |