Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
imtiaz_ullah
Creator
Creator

Change Sheet Colour Background using GetCurrentSelections

Hi guys,

Not sure if this is the right way to achieve this, but I am trying to change the background colour of a sheet depending on a particular selection within a dimension.

I am currently using - =if(GetCurrentSelections(SurveyQuestions)='TEXT TO LOOK FOR',yellow(),white()) and although I know the current selection text is correct (am throwing it out to a textbox), the colour of the sheet doesn't change.

Perhaps there are better ways to achieve this?

Thanks

Immy

1 Solution

Accepted Solutions
stigchel
Partner - Master
Partner - Master

Hi Immy,

You're welcome, the reason it first turns white again is because of the condition in the button's action. You can change it to e.g.

=if(GetFieldSelections(SurveyQuestions)='Text to look for A','','Text to look for A')

for the first picture and e.g.

=if(GetFieldSelections(SurveyQuestions)='Text to look for B','','Text to look for B')

for the 2nd

And for the Sheet color

=if(GetFieldSelections(SurveyQuestions)='Text to look for A',yellow(),

  if(GetFieldSelections(SurveyQuestions)='Text to look for B',red(),

white()))

Now when you click on a picture, the sheet will get the corresponding color, click the same again white and when you click on the other image it will immediately change to the other color.

Example attached again.

View solution in original post

14 Replies
imtiaz_ullah
Creator
Creator
Author

Figured it out... GetFieldSelections!

stigchel
Partner - Master
Partner - Master

Are you really sure?? When you use GetCurrentSlections the text I Aspect is "SurveyQuestions: TEXT TO LOOK FOR"

If you have takeb that into account, check capitalisation, qlikview is case sensitive.

You can better use

GetFieldSelections(SurveyQuestions)

So you don't have the extra text'. A working example is attached

imtiaz_ullah
Creator
Creator
Author

Yeah thanks Piet - I realised that in the end.

I have managed to get it work, but actually some odd behaviour still exists.

Essentially I have an image which when clicked I want it to apply a filter on the sheet. This in turn does "stuff", one of which is to change the colour background.

The only way I can see to do this is by adding an action to SELECT IN FIELD. Whilst this works and filters the sheet, the colour doesn't actually change. I have to actually select it within the list box.

It's almost like Qlik isn't simulating an actual click on the record in the list box when it does the SELECT IN FIELD action.

Does that make sense? If I click the actual record in the list box after, the colour changes, just not when I click on the image with the Action tied to it.

stigchel
Partner - Master
Partner - Master

No, it does not make sense. Are you sure the value gets selected in the correct field. I've attached a working example, if that does not help you, can you attach a qvw that demonstrates this problem?

imtiaz_ullah
Creator
Creator
Author

Hi Piet,

I get the message (attached) when trying to open the qvw...

Capture.PNG

Any ideas?

Thanks

Immy

stigchel
Partner - Master
Partner - Master

That message says you are using the (free) Personal Edition, which is only able to open qvw files created by others for a few times (I think 4). After that you can only use qvw files created by yourself. The option to embed a license in a qvw file is limited to QlikTech employees, which I'm not. So unless you get a license, you're unable to open my files, which brings me back to my previous question. Can you attach a qvw that demonstrates the problem?

If you are worried about data privacy, have a look at this:

Preparing examples for Upload - Reduction and Data Scrambling

imtiaz_ullah
Creator
Creator
Author

Good morning Piet - your example is almost perfect. It now works, although what is odd, is that if I have more than one picture to click on (in order to change background colour), I need to click the image twice each time as the first click sets the background back to white, the 2nd then turns it to the desired colour.

Thanks for you help thus far.

Immy

stigchel
Partner - Master
Partner - Master

Hi Immy,

You're welcome, the reason it first turns white again is because of the condition in the button's action. You can change it to e.g.

=if(GetFieldSelections(SurveyQuestions)='Text to look for A','','Text to look for A')

for the first picture and e.g.

=if(GetFieldSelections(SurveyQuestions)='Text to look for B','','Text to look for B')

for the 2nd

And for the Sheet color

=if(GetFieldSelections(SurveyQuestions)='Text to look for A',yellow(),

  if(GetFieldSelections(SurveyQuestions)='Text to look for B',red(),

white()))

Now when you click on a picture, the sheet will get the corresponding color, click the same again white and when you click on the other image it will immediately change to the other color.

Example attached again.

imtiaz_ullah
Creator
Creator
Author

Perfect! - Although now... If I click the same image once it's fine, if I click it again, it goes white, almost like I am removing the selection on the 2nd click?