In this article
Several of the dialogs within the Data Processing rules include an Expression field. This field allows you to create a filter expression such that only the data you require is included in the rule.
For example, say you would like to export only the records of female respondents. Assuming you have a question in the survey “What is your gender?”, with the answer options Male=1 and Female=2, you can generate an expression such as gender=2. When the rule is executed, the expression would remove any respondents with gender anything other than 2 from the data set. I.e. all males (with gender=1) would be removed, leaving only females.
You have two options when creating an expression; you can type the expression directly into the Expression field (on completion click Validate to check your code), or you can use the Expression Editor to assist you. To create an expression using the editor:
- Click the Edit button located beside Expression field.
- In the left column, search for or browse to the variable you wish to start your expression with, and click on it to select it.
- Click on the required Value/Parameter to select it.
- Select the radio button for the None operator (you cannot start an expression with the operators And or Or), and check the NOT box if required.
- Select the appropriate function and type any text or values into the Text or Number fields as required.
- Click Add Here to add the criteria to the Expression field.
- Select and add criteria until you have the required expression.
- On completion, click OK to apply the expression to the Expression field in the Rule Details pane and close the Expression Editor window.
- Click Save to save the changes.
The Expression Editor window opens - .
Figure 1 - Example of the Expression Editor window
The Values or Parameters (depending on the variable type selected) that apply to the variable will be listed in the second column.
Note: The status, respid, responseid, interview_start, interview_end and CatiExtendedStatus system variables will not be displayed in the list, but they can nevertheless be used in the expression. The syntax varies depending on the type of the variable. For example, the CatiExtendedStatus variable is numeric so it will typed as CatiExtendedStatus=13.
Note that the coding is displayed in the white text field and the expression is “written” below the field in full with colors to denote the functions.
The expression is now part of the rule and will be used to filter the data as appropriate.