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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Remove expression based on filter selection

I am in the process of trying to build a chart which shows values for a customer against the market average. Due to data confidentiality, the market average can only be filtered by one dimension (in this case "Class Of Business"), so what I would like to be able to do is hide the market average expression if the data is filtered on any dimension other than "Class Of Business".

Unfortunately I can't think of a way to achieve this. Has anyone got any ideas?

Hopefully I've been clear in what I want to achieve.

11 Replies
Not applicable
Author

Okey, I understand.

I have a solution but I think it's improvable...

In your chart, go to "Layout" tab. Check  "Conditionnal" in "Show" option. And the expression is :

=isnull(GetCurrentSelections())      /* NO SELECTION */
or                                                           /*     OR   */
(
     wildmatch(GetCurrentSelections(),'[Class Of Bussiness')    

     /* In the current selections,  there is a value which concern [Class Of Business] */


         and                               
         substringcount(GetCurrentSelections('||||'),'||||')=0    

     /* There is only one field where there is a selection (bof...)  */
)

Amand Dupretz

Not applicable
Author

I've just hit a similar problem myself and came across this thread while looking for a solution. While figuring it out I've found perhaps not the prettiest solution, but it works and I thought I would share anyway

So what I had is a chart (line graph) with two expressions, and five filters (in a multibox) against it. However, one filter is not relevant to one of the expressions and makes the comparison between the two expressions misleading if used, so I wanted to hide that expression if it's selected, and reveal it again if that filter is deselected.

I'll call the field in question that can be filtered fieldName for this example.

I first created two variables - countRecords and isFiltered, the latter I gave an initial value of 0

Under Document Event Triggers, I set an OnOpen trigger to Set Variable : countRecords = count(DISTINCT fieldName)

Under Field Event Triggers, I also set an OnSelect trigger against fieldName to Set Variable : isFiltered = if(count(DISTINCT fieldName) < countRecords, 1, 0)

Then finally I wrapped my chart's expression in the following : =if(isFiltered = 1, 0, (original expression))

Save & close, open it up again, and it works - I have a conditional expression in my chart which makes it disappear if a particular field is filtered. It's not elegant, but it's a quick fix that seems to work and that's all I need

Hope it helps point you in the right direction!