Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
Figured it out... GetFieldSelections!
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
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.
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?
Hi Piet,
I get the message (attached) when trying to open the qvw...
Any ideas?
Thanks
Immy
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
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
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.
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?