This blog post covers how to deal with the most common troubleshooting issues with filtering in Displayr.

1. How do I find resources on filtering?

2. My filter has become invalid

  • If you receive a red QFilter error then this signifies that there is an issue with the filter applied to your output:
    invalid filter output
  • You should find the filter under Data Sets, click it, and then update the condition where necessary.
    invalid filter variable
  • If the error is in a variable that your filter uses then it will indicate the invalid variable that requires fixing.
  • If the issue has been resolved but the output still shows as invalid, untick and tick Automatic.

3. Applying a filter to a visualization produces a warning

  • If you receive an orange warning like the below, this is because any filters should be applied to the source table rather than the visualization:filter warning
  • It will not affect your results but ensure the source table has the correct filter applied.

4. Applying a filter to my output produces a 0 observations error

  • If your table returns the below error but you expect there to be data, you should check the condition of the filter variable.
    filter no data
  • Check the raw data via Insert > More > Tables > Raw Data by selecting the filter variable and the source variables used in the condition. This will allow you to see if the issue is the actual data or simply the filter.

5. Applying multiple filters to my output doesn’t produce the desired result

  • Check the logic conditions in the individual filter variables.
  • Check the raw data via Insert > More > Tables > Raw Data by selecting the filter variables and the source variables used in the condition.
  • Check that the filter variables are grouped correctly. Non-grouped filters are treated as an AND condition whereas grouped filters are treated as an OR condition.
    • If your filters should be grouped (i.e. perform an OR condition), select them under Data Sets and go to Insert > Data Manipulation > Combine.
    • If your filters should not be grouped (i.e. perform an AND condition), select them under Data Sets and go to Insert > Data Manipulation > Split.

6. My R output doesn’t filter even though a filter is applied

  • If you have an R output with custom code that does not reference QFilter and then apply a filter, you will get the following warning:
    QFilter warning
  • QFilter is essentially a reference that stores the record-level TRUE/FALSE generated from the filter(s) selected under Input > FILTERS & WEIGHT > Filter(s). See Filters in Displayr for further details.
  • If you are dealing with a single variable, adding [QFilter] to your R reference will then apply the filter(s) selected on your output:
    QFilter R code
  • If you are dealing with multiple columns of data then [QFilter,, drop = FALSE] is more appropriate as the filter needs to specifically be applied to the rows while leaving the columns as is.

7. Unwanted filters are showing in View mode

  • By default, all filters in your document are visible in your published dashboard. Any filters you don't want to show can be hidden via the Hidden except in the data tree option:hiding filters
  • Note that you cannot hide filters that are currently in use in an output. You must do this prior to applying the filters.hiding filters warning
  • It is possible, however, for Q users to open their Displayr document QPack and set the filters hidden in the Variables and Questions tab using the H in the Tags column. Please use the workflow outlined in How to Edit a Displayr Document in Q.

8. I've opened my Displayr document QPack in Q and it's asking me if I want to reset my filters

  • While you can open Displayr documents in Q, filters that are created in Displayr work differently. In Displayr it is possible to group filters to allow you to join filter variables with OR. Q, by contrast, can only join filter variables with AND. If you select an output where such a filter exists, you should select No to maintain the current set up.
  • See the Combining filters section of How to Filter Data in Displayr for more details.

9. I'm trying to create a filter using R code but it doesn't work

10. I have unwanted items in my control box list

  • Items to be displayed come from both the Item list and Items from fields. By default, First option; Second option will appear under Item list but you can remove these. If you, therefore, have overlapping items listed between the two options, you will need to remove one of these duplicates:
    control item lists
  • If you are only using the Items from option, you can Hide items from the referenced table or amend your R code accordingly.

11. My output(s) won't update when connected to my control box(es)

  • Check Automatic is ticked on the output
  • If you are using manipulation settings: Check the correct control box has been referenced under ROW/COLUMN MANIPULATIONS > Rows/Columns to show and Select rows to show by is set to Choosing from Combo Box or List Box control.
    row manipulations
    Remember, if you have used the DATA MANIPULATION > Switch rows and columns option, you will need to apply these settings in the reverse manipulation menu.
  • If you are using filters: Check that you have applied the correct filter to the output and ensure any source table is included on the same page.
  • If you are using multiple filter variables, ensure they are all applied to your source outputs.
  • Check that the filter condition references the correct control box name.
    R filter reference error
    If using a Page Master, you will need to first find the correct template via Appearance > Page Master. Remember if you copy all the outputs from one page to another, the reference names will be different.
  • Check that the control box items match the source question being referenced. Remember that any merging of table categories for the source question will also need to be reflected in the control item list.
  • Check that you are using the correct formula as single and multiple-response questions require different code. See How to Connect Filters to a Combo Box (Control) for further details.
  • Below is an example of a single-response condition based on the categories from Age: 
Age %in% Combo.box
  • And this is an example of a multiple-response condition based on the variables from Rolling months:
rowSums(`Rolling months`[, Combo.box, drop = FALSE]) > 0
  • If you are using a filter variable that combines all the conditions, ensure they are all connected with the & (AND) symbol. For example:
Age %in% combo.box.age & Gender %in% combo.box.gender
  • If you are using a single-response question as the basis of your control categories but have created overlapping NET categories, you will need to set this up instead as a set of binary variables. You can easily do this via Insert > Filter > Filters from Selected Data. You will then need to adjust the filter formula to reference these new filter variables.

12. I added a total sample item to my control box but my output(s) won't show total base

  • Check the formula condition in your control filter variable. Filter variables need to return 1 or TRUE when selecting records and 0 or FALSE when not selecting them.
  • The general way for setting a 'total sample' default among custom filter categories is by adding an if/else statement. Below is my existing filter condition:
usergroups %in% Combo.box.groups
  • I also have an item in my combo box called Total Sample so I need to add that condition and wrap it all within an if/else statement. To do this I can use the rep function and reference the length of the id variable which signifies the number of records in the file. This will then generate a 1 for every record in the data set if this condition is TRUE, otherwise, it will return the second filter condition.
if ("Total Sample" %in% Combo.box.groups) {
rep(TRUE, length(id))
} else {
usergroups %in% Combo.box.groups
}
  • If 'total sample' is instead based on another filter variable, check its logic condition.
  • Check any applicable raw data via Insert > More > Tables > Raw Data by selecting the filter variable and the source variables used in the condition.

13. I've applied a filter in View mode but it is no longer applied when I go to another page

14. I'm trying to export reports with selected filters but my reports aren't filtering properly

  • The Select multiple filters to export multiple reports option requires all underlying tables and outputs to be on visible pages. Any items on hidden pages will not be filtered. It works in the same way as applying page filters from the Filters drop-down menu in View mode.
  • If you are using tables as the underlying data, you should place them on the same pages as your final outputs.
  • If you are using R outputs as the underlying data, these also need to be filterable, that is, they need to reference QFilter in the code. Unless you are using a custom R output, this will already be included in the underlying R code.
  • See How to Automatically Export Multiple Reports with Different Filters for further details.

15. I'm trying to display the sample size description but it won't show the filter label based on the control box

  • When filtering data through a control box, you may wish to display the sample size description via Insert > More > Data > Sample Size Description. In this case, the underlying code behind the widget won't be able to deal with this by default. To customize your code, go to the Advanced Customization: Dynamic updating with Combo or List Boxes section of How to Customize the Sample Size Description Widget.