Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Remove/add rows based on the value of a variable

I have a dimension (let's call it dim1) with three values: A, B, and C. There's a button which toggles the value of a variable (let's call the variable vButton) between 0 and 1. This is what I'd like to happen. When vButton is 0, all charts will reflect only the rows associated with A and B in dim1 (as if the rows associated with C didn't exist). When vButton is 1, all rows in the dataset (including the ones associated with C) will be used to populate the chart. Essentially, based on the value of vButton, some rows will be temporarily removed or added back.

I'm new to Qlik and I'm puzzled as to why this seems so difficult to do. I tried set expressions, but that seems to be chart specific. I could probably write set expressions for each chart, but that sounds unnecessarily complicated. How should I go about solving this? Thanks a lot in advance.

8 Replies
Gysbert_Wassenaar

Instead of a Set Variable action you can use a Toggle Select action and directly toggle the selection of the value C in the field. This is easier than using a variable. But perhaps you want to apply this selection only to one chart. In that case using a variable makes sense. You can use a calculated dimension: =if( $(vButton) =1, if(dim1<>'C' ,dim1), dim1).


talk is cheap, supply exceeds demand
marcus_sommer

If you want to avoid hard-coded conditions within the expressions for all these objects you will need to add your logic within the datamodel. This meant to create a flag-field from 0 or 1 to your data which then could be queried within the expressions per set analysis like:

sum({ < Flag = {">=$(vButton)"}>} YourValue)

whereby the 0/1 logic is reversed to your suggestion - which meant that 1 = limited dimension and 0 = all dimension values.

Another possibility which didn't require an expression-condition but more efforts within the datamodel might be the approach from The As-Of Table.

- Marcus

Anonymous
Not applicable
Author

Thank you. I'm afraid I'm too new to the Qlik world to follow your explanation.

you will need to add your logic within the datamodelo. This meant to create a flag-field from 0 or 1 to your data which then could be queried within the expressions per set analysis like:

sum({ < Flag = {">=$(vButton)"}>} YourValue)

Could you point me to any documentation to help me better understand how to do that?

I want all the charts to change with the change in value of the variable. I believe you're suggesting that I use set expressions in each chart's measure. Is that correct? This doesn't sound like an efficient way achieving a global change.

Anonymous
Not applicable
Author

Thanks. To be clear, I want to apply my selection to all the charts.

Is there any documentation about how to use toggle select? I see this in the api, but for that I need to use mashups/JavaScript. I'm working on the dashboard sheets however. Is this something I can use in expressions?

marcus_sommer

The normal and more recommended way to use qlik is to use normal selections and not to involve any macros, actions or variables within them. Of course there are more and enhanced ways to create your usability but the needed know how and the efforts to implement this could become very sophisticated and comprehensive. Therefore try to cover everything with normal selections and use other ways only for this situations where you have special requirements.

Let the User Select

To get a better unstanding what's meant with flags have a look here: Customized flags.

- Marcus

Gysbert_Wassenaar

Toggle Select is described in the help file. For example in the Qlikview 12 online help page for the Button object (Button ‒ QlikView😞

Toggle SelectToggles between the current selection and the specified Field and Search String. In theSearch String you can specify a search mask, e.g. (A|B) will select both A and B.

This action works on the document level. It simply changes the selection of one value. This is useful if, like you mention, you want it to apply to all charts. It is an action and actions cannot be used in expressions. Actions can only be assigned to triggers and some types of objects like buttons, text boxes, line/arrows and gauge charts.


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

I'm sorry that it wasn't clear: I'm using Qlik Sense. Thanks nonetheless.

Gysbert_Wassenaar

No, my mistake. I should have noticed you posted this in the New to Qlik Sense space. Actions aren't implemented yet in the Qlik Sense UI yet. But there is an extension available that does offer an interface to define actions: GitHub - stefanwalther/sense-navigation: Sheet Navigation + Actions for Qlik Sense. I haven't tried the selection actions yet, so I'm not 100% sure your requirements can be implemented with this extension.

An alternative is to define a master dimension and use that in your charts. You'll only have to define the master dimension once and then you can use it in any chart you need it. The master dimension is defined as an expression that checks the value of your variable and includes or excludes C: =If( vButton=1, if(dim1<>'C', dim1), dim1).


talk is cheap, supply exceeds demand