It is not uncommon for dashboards to have multiple combo box filters. In the following example, there are four of them: Gender, Senior Citizen, Partner, and Dependents.
Too many combo box filters can become inefficient and slow. To avoid this problem, we recommend condensing all the filters into a single filter.
For example, let's say you have 20 separate filter variables and 10 tables with those filters applied. Without condensing them this is how it works:
- Every separate filter has to be calculated to identify the records that match the filter.
- Then, as every table calculates, it has to match up each of the 20 filters together to find out exactly which respondents qualify. It has to do this separately on each table before the table can run.
- So in the end it's 20 filters to calculate, then 10 additional calculations for the tables even before the tables can run.
- The filter runs once and identifies the right respondents.
- Each table only needs to use the single filter's data to run.
- So 20 filters become 1, and you also save the additional step of each table combining the 20 filters to find the right respondents.
Requirements
A Displayr document with multiple combo box filters
Method
- From the toolbar, click Anything
> Data > Variables > New > Custom Code > R > Numeric. This will add a new variable called newvariable in the Data Sources tree.
- Select newvariable from the Data Sources tree, and in the object inspector, click the General tab and update the variable Name and Label to names of your choice. In this example, we will call it CombinedFilter.
- With the CombinedFilter still selected, type the names of each of your combo box filters on separate lines in the R Code window. Then add a line of code that adds them together. For example:
- Close the R Code editor window before proceeding to the next steps.
- In the Data Sources tree, click on each existing combo box filter variable one at a time and copy the R Code, which can be found by going to Data > R Code - Data > Edit Code in the object inspector. Then paste the name into the R Code editor on the appropriate line of your CombinedFilter variable.
For example, this is the code in the Gender filter variable
... and what it looks like after pasting the code into the CombinedFilter R Code window: - Repeat the previous step with each of your other combo box filters. After you are finished, the completed R Code window for your condensed filter variable should look like this:
- In the object inspector for CombinedFilter, tick Usable as a filter under Data > Properties.
Finally, you need to ensure this is the only filter applied to each of your outputs.
- Select each output on the page (or select the entire page in the Report tree), and select Data > Filters & Weight.
- Uncheck each box corresponding with the original filters.
- Then select CombinedFilter as the only filter variable.
Next
How to Create a Combo Box Filter
Reduce the Number of "Things" and the Size of the "Things" in a Document