Examples: Creating Complex Filters using the Filter Syntax Pane

You can use the Filter Syntax pane to edit filters that you have set up using the Filter pane. In addition, you can create complex filter expressions that are not possible using the options available in the Filter pane. The following examples show how to create a number of complex filters.

Note: If you create a filter using the Filter Syntax pane that it is not possible to create using the options in the Filter pane, the message: The filter expression could not be displayed is shown in the Filter pane when you choose the Apply button. This is as expected, and does not prevent the filter from being applied to the table.

Include exactly these categories

Suppose that you want to create a filter for the remember variable to include only people who remembered the Dinosaurs and Fossils galleries but no other galleries. Here is an example of the syntax to do this:

remember.ContainsAll({Dinosaurs,Fossils}, True)

The True parameter restricts the filter to respondents who chose Fossils and Dinosaurs and no other galleries. If you wanted to select respondents who chose both Fossils and Dinosaurs regardless of whether they chose any additional galleries, you can use the same syntax without using True (this option is equivalent to choosing the Includes any of these option in the Filter pane):

remember.ContainsAll({Dinosaurs, Fossils})

Include at least 2 of these categories

You might want to include only people who remembered two or more of the Dinosaurs, Fossils, and Evolution galleries, regardless of whether they remembered other galleries. Here is an example of the syntax to do this:

remember.ContainsSome({Dinosaurs, Fossils, Evolution},2)

Include between 2 and 3 of these categories

Suppose that you want to create a filter to include only people who remembered at least two, but no more than three, of the Dinosaurs, Fossils, Evolution, Birds, or Mammals galleries (regardless of which of the remaining galleries they remembered). Here is an example of the syntax to do this:

remember.ContainsSome({Dinosaurs, Fossils, Evolution, Birds, Mammals},2,3)

If you want this filter to exclude people who remembered any other galleries, you can add the True parameter to this syntax:

remember.ContainsSome({Dinosaurs, Fossils, Evolution, Birds, Mammals},2,3, True)

Include at most 3 of these categories

You might also want to create a filter to include only people who remembered up to three of the Ecology, Wildlife in Danger, Botany, Conservation, or Fossils galleries (regardless of which of the galleries they remembered that are not on this list). Here is an example of the syntax to do this:

remember.ContainsSome({Ecology, Wildlife_in_Danger, Botany, Conservation, Fossils}, , 3)

Again, if you want this filter to exclude people who remembered any of the other galleries not on this list, such as Dinosaurs or Whales, you can add the True parameter to this syntax:

remember.ContainsSome({Ecology, Wildlife_in_Danger, Botany, Conservation, Fossils}, , 3, True)

Include only 1 of these categories

To create a filter to include only people who remembered the Dinosaurs gallery but not the Fossils gallery, or the Fossils gallery but not the Dinosaurs gallery, regardless of which of the remaining galleries they remembered, you can use the following syntax:

remember.ContainsSome({Fossils, Dinosaurs}, 1, 1)

Again, if you want this filter to exclude people who also remembered any of the other galleries, you can add the True parameter to this syntax:

remember.ContainsSome({Fossils, Dinosaurs}, 1, 1, True)

These examples use functions from the IBM® SPSS® Data Collection Function Library. See the topic Function List for more information. For full details, see the Expression Evaluation and Data Collection Function Library topics in the Data Collection Scripting section of the IBM® SPSS® Data Collection Developer Library.