Countless use cases call for the use of toggles. In this blog, we’ll summarize the most common use of toggles with implementation examples. Let’s begin:
Implementing the Toggle
The easiest way to implement a toggle is to take two “On” and “Off” images and lay one atop the other using two Text objects.
In order to switch between “On” and “Off” images, we’ll need to use variables. Let’s create three variables: vOnOff1, vOnOff2, and vOnOff3. Set the default value to 0.
For the (Off) text object, go to Properties, create New Action and set vOnOff1 variable to 1. Also, switch to Layout tab and set Show Conditional to “=if(vOnOff1=0,1,0)”
For the (On) text object, go to Properties, create New Action and set vOnOff1 variable to 0. Also, switch to the Layout tab and set Show Conditional to “=if(vOnOff1=0,0,1)”
That it! Clicking the “Off” image hides the object and displays the “On” image instead. Clicking the “On” image does the reverse.
Now let’s look at the most common use cases for toggles:
For applications that use several tabs it may be advisable to hide infrequently used tabs to create a cleaner UI. This can be achieved with something like Settings tab that includes multiple toggles, one for each tab. Then we can limit the default view to a handful of tabs and enable the extra tabs as needed.
Hide one tab while enabling another tab on the same toggle
This is identical to the first use case, with the exception that one tab would be visible on Show, while another becomes visible on Hide.
Create Control Charts that can be enabled or hidden, implemented in the same manner as conditional show/hide tabs.
Swap calculation type within charts
For example, to toggle between Percentage and Numbers we would use conditional enable for Expression.
Add/remove columns in table charts
Similar to changing a calculation in a chart, we can add/remove columns in table charts. This approach makes the most sense for adding—let’s say—one extra column. To provide an ad-hoc selection of all columns in a table we would use load Dimensions and Measures into the data model, as described in this example: https://community.qlik.com/docs/DOC-5404
Tagging data points in Qlik
Toggles can even provide the ability to tag specific data points in Qlik for a write-back to the source (but that’s a topic for another blog).
This approach is applicable to both QlikView and Sense. Though Sense offers greater flexibility to use pre-built extensions to implement the actual toggle. Happy toggling!
Business Intelligence Architect