Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Not applicable

Variable icon to trigger field selection

Dear Community,

I am now trying to use variable to trigger a field selection.

My requirement:

If i click on grey variable icon, the twitter field will be selected and the icon is turned to red variable icon.

If i click on red variable icon, the twitter field will be De-selected and the icon is turned to grey variable icon.

1. Add action to the field

2. Add action to variable

3. if i click on the red variable icon, it will trigger to select the socialchannel as shown below:

4. if i click on that red variable icon, it will turn to grey variable icon, and deselect socialchannel as shown below:

5. Problem come when I click on the grey variable icon, it shows the red variable icon, but the twitter field in socialchannel is not selected. No matter how many times i click on grey and red icon, the field is not selected anymore.

6. It can work only i click on the twitter in the list box selection, but again only work for one time. I dunno why the field is not selected and deselected accordingly to the change of variable.

Anyone can help?

Thanks and best regards,

Chanel

1 Solution

Accepted Solutions
MVP
MVP

Re: Re: Re: Variable icon to trigger field selection

Hi Chanel,

I have finally found a few moments to take a proper look at your example.  Please find attached a working example - I hope I have understood your requirements correctly.

The action for toggling is done using the Selection and Toggle Select options.  The on and off buttons have exactly the same code behind them.

The expression that decides which button is shown is this:

index(GetFieldSelections(SocialChannelSource), 'Twitter') > 0

or

index(GetFieldSelections(SocialChannelSource), 'Twitter') = 0

If you want all red buttons to show when nothing is selected (ie. everything is 'possible') then you could use this instead:

index(Concat(SocialChannelSource), 'Twitter') > 0

I have also added a few text boxes that toggle the next few social media channels.  Rather than having two buttons that show and hide this changes the colour of the text box using this code in the calculated colour field:

=if(Index(GetFieldSelections(SocialChannelSource), 'Boards') > 0, rgb(255, 20, 20), rgb(50,50,50))

If you created images that had white symbols with a transparent background to place over these text boxes you would have more control over colours etc. from within your document - just a thought.

Hope that helps.

Steve

17 Replies
MVP
MVP

Re: Variable icon to trigger field selection

Hi Chanel,

I would look at implementing this without the use of Triggers.  I think the issue you are having may be that the triggers are not firing in the order you are expecting - but rather than try and debug this I would go for the following.

Set red and grey buttons up to select Twitter and clear channel respectively.

Test these both independently.

Set one button to only show on this condition:

=GetSelectedCount(SocialChannelSource) = 1 and Only(SocialChannelSource) = 'Twitter'

Set the other button to only show on the inverse:

=GetSelectedCount(SocialChannelSource) <> 1 or Only(SocialChannelSource) <> 'Twitter'

Move both buttons so that they are in the same location with the same size properties.

This should then achieve what you are after.   Please post back if it does not.

I produced a blog post, example QlikView and Video on dynamic buttons, which may be off interest to you?  You can find that here: http://bit.ly/15PEpQ9

Kind regards,

Steve

http://www.quickintelligence.co.uk/

Not applicable

Re: Variable icon to trigger field selection

Dear Steve,

Thanks very much, it did improve much.

Just one problem, when i click on grey icon, it dint trigger anything.

It will only work again when i select the the twitter in SocialChannel listbox as shown below:

My aim is to let user select the socialchannel without listbox, but just clicking on the icon.

When they click grey twitter icon, then twitter is selected, if they click on red twitter icon again, twitter will be deselected and the icon will change to grey.

There are few more types such as facebook, blog and board will be added.

User is able to select more than 1 type at the same time.

Example:

I have attached the .qvw file, kindly help.

Thanks and best regards,

Chanel

Not applicable

Re: Variable icon to trigger field selection

hi

Chanel


see my attached i hope can help.


regards,

Gernan

preminqlik
Valued Contributor II

Re: Variable icon to trigger field selection

hi

PFA

Regards

premhas

Not applicable

Re: Variable icon to trigger field selection

Awesome! Thanks pretty much!

MVP
MVP

Re: Variable icon to trigger field selection

Hi Chanel,

The method I described above would require the use of the Select In Field and Clear Field actions on the button - rather than the set variable.  The code that then dictates which button would show would work regardless of whether the value was set by pushing the button or selecting in the list box.  The variables and triggers then becomes redundant.

I have found this approach to be more robust in the past.


- Steve

Not applicable

Re: Variable icon to trigger field selection

Hi Premhas,

can we select more than one channel at same time?

For example, we have twitter, facebook and blog icon,

I can select more than one channel.

User requests to see icon selection instead of listbox.

I know that listbox, pivot table, multibox can show icon but the effect is not that neat.

Regards,

Chanel

Not applicable

Re: Variable icon to trigger field selection

Hello Chanel,

You can use Select in Field in action of all the four images.

Select in field: Field: 'Social channel' String: 'Twitter' for the twitter image. Subsequently do the same for rest.

For the grey image also, you can add a similar action.

If you still want to persist with using triggers, you can try the on change trigger for the same variable. When the channel gets cleared that trigger will be activated.

I hope this helps

Thanks,

Vishal


MVP
MVP

Re: Variable icon to trigger field selection

Hi Chanel,

The code to highlight the buttons is quite simple.  For the red button:

=if(maxstring({<SocialChannelSource={'Twitter'}>}SocialChannelSource) = 'Twitter'


This checks if Twitter is among the currently selected (or possible) channels.


Just invert this for the grey button:


=if(maxstring({<SocialChannelSource={'Twitter'}>}SocialChannelSource) <> 'Twitter'


You then need the equivalent versions for other channels.


Setting the values in the list box on button click will be a bit more tricky - as you need to add or remove values from the selection on click (rather than replacing or clearing the selection).


Personally, I would go for a set of variables (vTwitterState, vFacebookState) and toggle those between 0 and 1.  And then apply those using a dynamic bit of Set Analysis.


If data volume are low a way to do it without variables and triggers is would be this:  You could load an inline table for each Channel like this:


TwitterSelect:

LOAD

    SocialChannelSource

     1 as TwitterSelected

INLINE [

SocialChannelSource

Twitter

];


Then your button actions would just need to SelectInField for TwitterSelected the value of 1 or clear the selection in TwitterSelected (and equivalent for each other channel).  This feels a bit kludgy - but is simple to implement and understand.


Hope that helps.


Steve

http://www.quickintelligence.co.uk/


Community Browser