Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
Jennell_McIntire
Employee
Employee

Conditional show or hide is available in line and bar charts giving the user the ability to toggle dimensions or measures on or off in a single chart. This allows developers to customize line and bar charts and save space by using one chart to show various metrics and dimensions. Let’s look at a simple way of using this feature to show or hide lines in a line chart. In the Overall Equipment Efficiency demo found on the Demo Site, there is a line chart accompanied by buttons that are used to toggle the lines on and off in the line chart.

demo.pngThis is done by using variables. When each button is clicked, the respective variable is toggled from 0 to 1 or 1 to 0 depending on its current value. See the value expression in the image below.

variable.png

 

 

 

 

 

 

 

 

 

 

 

In the measure expression in the line chart, this variable is checked to determine if the expression should be evaluated and displayed or if the measure should be set to null.

if.png

 

This is a perfectly good way to toggle the lines, but with the ability to use conditional show and hide in line and bar charts, this process can be simplified. First, in the measure expression, we no longer need to use an if statement which can help reduce calculation time. We can simply use our normal expression and the “Show measure if” setting, with the respective variable, to evaluate if a line should be shown in the visualization or not.

show measure if.png

 

 

 

The “Show measure if” and “Show dimension if” settings evaluate the expression and will show the line if the expression evaluates to true. In my example, vShowOEE will be either 1 or 0. If it is 1, the line will be displayed. If it is 0, then it will not be displayed. We can continue to use the buttons to toggle the respective variable (from 1 to 0 and vice versa) for each line.

My example is basic, but more complex expressions can be used as well. For example, you may want to show/hide lines based on a selection or a calculated value or you may want to use some business logic to determine which dimension or measure should be displayed. The expression can be as simple or complex as needed, as long as it returns a true or false value. Keep in mind, that this show setting is optional and can be left blank. When no expression is entered, the line (or bar) is displayed.

There are a few limitations of this new feature to be aware of: 1) Custom tooltips are disabled when using a conditional dimension, 2) Time series forecasting is not available when using conditional dimensions or measures. While the “Show measure if” and the “Show dimension if” can both be used in the same chart, it is recommended that you use only one at a time. Check out Qlik Help to learn more and test this new feature out in your next line or bar chart.

Thanks,

Jennell

5 Comments