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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
a-5
Contributor III
Contributor III

Hide/show measures in bar chart based on condition

Hi, 

In my sheet, the user can choose whether to see the actual result against FY target only or both YTD & FY targets. 

How can I create a condition in my bar chart that:

- If the user has selected "FY" in filter, only FY target bar is shown in the bar chart 

- If the user has selected "YTD" in filter, both FY & target bars are shown in the chart?

Bar representing the actual result is also already included in the same chart.

I want to show the relevant measures only in the legend. Meaning if user has selected "FY" in filter, actual and FY target measures are shown in the legend only (YTD target is not shown in the legend). 

 

Thanks!

Labels (3)
1 Reply
Sayed_Mannan
Creator II
Creator II

To achieve this , you can use the "Show measure if" setting for conditional display of measures. Here's how you can set it up:

1. Create a Filter for Selection: Ensure you have a filter for the user to select either "FY" or "YTD".

2. Define Variables: Create variables to capture the user's selection. For example, vShowFY and vShowYTD.

3. Set Up the Measures with Conditions:

For the FY target measure, use the "Show measure if" condition:

GetFieldSelections(YourFilterField) = 'FY'

For the YTD target measure, use the "Show measure if" condition:

GetFieldSelections(YourFilterField) = 'YTD'

4. Add the Measures to the Bar Chart:
:-  Add the actual result measure as usual.
:-  Add the FY target measure with the condition applied.
:-  Add the YTD target measure with the condition applied.

Here I'm giving an example of how you can set up the measures:

// Actual Result Measure
Sum(ActualResult)

// FY Target Measure
If(GetFieldSelections(YourFilterField) = 'FY', Sum(FYTarget))

// YTD Target Measure
If(GetFieldSelections(YourFilterField) = 'YTD', Sum(YTDTarget))

 

I hope this help.