Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
alanmcgrath
Creator
Creator

Using Checkboxes to show/hide expression in chart

Hi everyone,

I am trying to create a chart that allows selection of expressions via a checkbox.  I was able to get it to work when having one list box of metrics to select from.  However, due to the amount of metrics in the list box I would like to separate into smaller list boxes.  The issue is once I have separated into a few list boxes I cannot select metrics from each of the list boxes and have them display, it only displays selections from one list box at a time.  Any suggestions on how to allow selecting from each list box an have all those selected display?

Here is how  create the separate list boxes:

Metrics:
Load * Inline [_metrics, Flag
Sales %,1
SalesHrs,1
Training %,1
Training Hrs,1
   Overtime %,1
Overtime Hrs,1
Recovery %,1
Recovery Hrs,1
Total Hrs,1
Unassigned %,1
Unassigned Hrs,1

Attrition Avg Headcount,2
Attrition Avg HP Headcount,2
Managed Leavers,2
Managed Attrition %,2
Total Attrition %,2
  Total Leavers,2
  Unmanaged Leavers,2
Unmanaged Attrition %,2
 
Headcount FTE,3
Headcount Heads,3
Joiners FTE,3
Prior Year End Headcount,3

Then in the listbox I am using an expression to display the metrics by "Flag".  =If(Flag=1,_metrics)

For the Chart I have all the metrics listed and then am using substring counts to display.  So in the general tab I have the calculation condition of GetSelectedCount(_metrics)>0 .

Then in the expression section I have each one listed and in the conditional section I have the formulas =Substring(Concat(_metrics,'|'),'Overtime Hrs') This is an example of the overtime hrs conditional statement, obviously each expression has the specific title.

When I click on a metric from the list box with Flag 1 it displays fine, but the issue is when I want to also see a metric from the box with Flag 2 or 3, it is dropping the metric from the Flag 1 box.

Any way I can fix this??

Thanks!

11 Replies
alanmcgrath
Creator
Creator
Author

Awesome, thanks!  So a simple IF statement is all I needed.  I knew it was something fairly simple I was missing.  This works great, Thanks again!

jonathandienst
Partner - Champion III
Partner - Champion III

Are the metrics in the listboxes all subsets of the same field (_metrics)? If so, you could use an alternate state trick.

Place each list box into a different alternate state (Create the states first in Document Properties | General). This means that you can independantly select items in each list box.

Now to 're-assemble' the selections, modify the expression like this:

SubStringCount(Concat({State1} _metrics,'|')

     & '|' & Concat({State2} _metrics,'|')

     & '|' & Concat({State3} _metrics,'|'), ,'Sales %')

SubstringCount is searching through the values for all 3 states. Add more states for more listboxes and update the expression accordingly.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein