This blog shows how to create a filter. Before reading this blog, make sure you check out Using Displayr to filter data, analyses, and whole reports, which describes what filters can do in Displayr.

Click here for an interactive tutorial on filtering


 

1. Creating simple filters from the ribbon

The simplest way to create a filter is to select Insert > Variables > Filter (see below) and choose the variable or pair of variables that you wish to create a filter.

Filter in Ribbon

When you create a filter by pressing the buttons in the ribbon, you are both creating a filter and applying the filter to any currently selected outputs or pages. All the other methods described in this post create, but do not apply, filters.


 

2. Tagging a variable as a Filter

Any non-text variable set in Displayr can be set as a filter.

  1. Select the variable in Data (bottom-left of the screen), and
  2. Choose Usable as a filter from Properties (right-middle of the screen).

Cases that have a value of more than 0 are included in the filter.

Usable as a filter steps

 


 

3. Quickly creating lots of filters

To create lots of filters:

  • Select the variable sets you wish to use to create the filters from Data (bottom-left of the screen).
  • Insert > Filter > Filtering > Create Filters from Selected Variables.

A particularly useful aspect of the way that this works is that if you have merged together any of the categories in a variable set (see Introduction to Displayr 3: Creating tables, charts, and other visualizations), the new variables will be based on these merged categories. Also, if you wish you can modify these filters by changing their underlying JavaScript code, which we'll look at next.

Create filters shortcut

 


 

4. Creating new R and JavaScript variables

New variables can be created using R and JavaScript (Insert > Variables). If these variables are tagged as filters (see method 2 above), they can be used as filters, with any values greater than 0 being included in the filter (i.e., when such variables are applied as filters, only the data for cases with values of more than 0 on the filter variable will be used).

3 steps to filter with code

A great example of how to create an R filter based off of the value in a drop down control box is on our blog here.


 

5. Variable Set Structure

This is a more exotic approach than the others, but can be a huge time saver. When the structure of a variable set is changed to either Binary - Multi or Binary - Grid the values of the variables are automatically recoded to be 0s and 1s, and you choose which values are converted to 1s and which to 0s. Then, select Use as a filter for the variables.

Binary - Multi as filter