17 Replies Latest reply: Oct 6, 2013 9:41 PM by Chanel Choo RSS

    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

        • Re: Variable icon to trigger field selection
          Steve Dark

          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/

            • 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

                • Re: Variable icon to trigger field selection
                  Steve Dark

                  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

              • Re: Variable icon to trigger field selection

                hi

                Chanel


                see my attached i hope can help.


                regards,

                Gernan

                  • Re: Variable icon to trigger field selection

                    Awesome! Thanks pretty much!

                    • 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

                        • 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

                           


                          • Re: Variable icon to trigger field selection
                            Steve Dark

                            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/


                              • Re: Re: Variable icon to trigger field selection

                                Hi Steve,

                                 

                                Thanks for proposing so many ways to solve it. I tested them but seems like not working correctly.

                                Attached herewith the .qvw file, icons at the left hand side is show conditionally with your provided code, but it is not working accordingly.

                                Solution at the right hand side is working, but we can only select one value in the field, I am figuring how to select more than one value in the field, such as select both Blogs and Twitter... Appreciate if you could help!

                                For the toggle solution, I am not really sure how it should function, maybe you can help to edit the attached example?

                                 

                                Thanks and best regards,

                                Chanel

                                  • Re: Re: Re: Variable icon to trigger field selection
                                    Steve Dark

                                    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

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

                                        Dear Steve,

                                         

                                        Awesome! It is working pretty nice:

                                         

                                        But I am thinking there might be limitation or bug:

                                        If i select one by one, it is working fine until facebook:

                                        but when i tried to click on twitter to select it, it turned all other channels to grey:

                                         

                                        But weird thing is if i select reversely from boards to blog, it is working pretty good!

                                         

                                        I am not sure it is bug or some little mistakes I made in my document, so I attached again my .qvw file.

                                        Again, thanks for your awesome help! I am nearly there!

                                         

                                        Thanks and best regards,

                                        Chanel

                                          • Re: Re: Re: Re: Re: Variable icon to trigger field selection
                                            Steve Dark

                                            Hi Chanel,

                                             

                                            The actions on the grey version of the Boards button had the wrong actions on there - it is setting a variable and selecting in field rather that doing a toggle in field as per the other buttons.

                                             

                                            After doing some further playing with the document, you may well find things behave better if you use the code:

                                             

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

                                             

                                            The reason for this is because if you select all items then the GetFieldSelections returns 'ALL', also if you pick all but Twitter it returns 'NOT Twitter' - this will throw out the highlighting.

                                             

                                            You may also want to select all with a trigger on Open and on Reload, do this with a Select in Field and a value of *.  You also would want to select all when the selection is cleared (so you never have no selections - which will throw the first toggle).

                                             

                                            I've tweaked your document so you can see that approach in action.

                                             

                                            Hope it helps,

                                            Steve

                                             

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

                                    • Re: Variable icon to trigger field selection
                                      Prem Kumar Thangallapally

                                      hi chanel....

                                       

                                      first u prepare a list box with all field values... try what i did before....lets c ...