Many times, you want the viewer of your dashboard to be able to filter or choose what categories or series are shown to them in visualizations. You can add this interactivity to your dashboard with a Control, and then hook the control up to your tables/visualizations (without using R code!) to toggle which categories are shown. This article describes how to use a Control Box (i.e. combo box, list box, or other control) to select which rows or columns from your table are shown in a visualization. There are two methods, depending on your outputs
- Method - Using the Select Matching Rule: use this on the visualization input tables or legacy visualizations.
- Method - Using the Select Row/Columns to show by field: use this on R-based visualizations when you want the input table to remain intact.
The post contains the steps required to go from a page with a visualization showing data for all age groups...
...to a Page where the user can select which age groups (columns) to show based on a Control Box selection.
Requirements
- A Control Box control such as a Combo box or List box. These are added via the toolbar, Anything + > Page Design > Control menu.
- A table or visualization.
- An above-mentioned output type with row/column labels matching the Item list or Items From field in object inspector of the Control.
Method - Using the Select Matching Rule
You can apply a rule to the input table for the visualization to only show the rows or columns in the combo box. This will, in turn, only plot that subset of data in the visualization made from that table. You can also apply the rule directly to legacy visualizations labeled "with tests". Some specialty tables do not support rules (such as Table with Custom Formatting) and must use the dropdown method below. For more details on how to use this rule, see: How to Select and Sort Rows and Columns Based on Another Item.
- Click on the input table of your visualization, and from the object inspector, navigate to Data > Rules > + > Rows/Columns.
- Select either the Select Matching Columns or Select Matching Rows rule.
- In the Select columns/rows using field, select the control you'd like to use (such as ComboBoxAge in the picture below).
- [Optional] If desired, you can keep the original order in the table by changing Order columns based on > original order.
- Click OK.
- Your table and any visualizations linked to it will update according to what is shown in the combo box.
Method - Using the Select Row/Columns to show by field
For R-based visualizations and outputs where Rules cannot be applied, you can use a dropdown in the object inspector to enable them to only show the selection in the control.
- Select your visualization/output and in the object inspector select Data > Row Manipulations/Column Manipulations > Select Row/Columns to show by > Choosing from Combo Box or List Box control.
- In Row/Columns to show, select the Control Box you wish to use to select the data. Ensure that the Control Box list matches the labels used in rows/columns of your output/data source. In this example, the Control Box List contains the different Age groups as seen in the columns of the table below the visualization above.
Next
How to Filter Rows and Columns in Visualizations and Tables Without Code
How to Select and Order Rows or Columns to Show in a Visualization Based on a Calculation
How to Create a Combo Box Filter
How to Connect Filters to Controls Using R Code
How to Create a List Box Filter
How to Create a Text Box Filter
How to Create a Combo Box (Drop-Down Control) With a Dynamic List