Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Change the background colour based on a selection

Dear all,

I have the following Qlikview file in which I have created three pictures. Each of the pictures should fill the variable vColour1 with a different value. Then the background of the table box in the file should change based on the selection.

I have taken the following steps

- In the properties of the text objects (pictures) I have classified the actions "Select in field" and classified them as Label with a text.

- The I added the following code in my load script:

SET vCurrentLabel = LABEL;
SET vKleur1
= if ( vCurrentLabel = 'Eneco Consumenten B.V.' , RGB(210,18,66), 
( if ( vCurrentLabel = 'Oxxio', RGB(0,122,156), 
( if ( vCurrentLabel = 'WoonEnergie', RGB(209,221,27), 
RGB(236,116,15) )))));

Now when I click on the first picture (Eneco) I see the background is indeed changing to right colour((210,18,66). However when I click on of the other labels the background is not changing while I was expecting that when I clicked on the Oxxio picture the background would change to (0,122,156).

Could anybody see what goes wrong here?

Cheers,

Marc

5 Replies
Anonymous
Not applicable
Author

Hi Marc, You may need to add the .qvw file for us to look at.

Just ensure your descriptions are not case sensitive and that selections are exactly the same as in your if statement.

Should be names and nothing too complex.

Kind regards

Chris

Gysbert_Wassenaar

My guess would be that your select in field actions are not entirely set up correct. But I can't see that from here. Perhaps you can post a small qlikview document that demonstrates the problem.


talk is cheap, supply exceeds demand
c_gilbert
Creator II
Creator II

To test this to see where it is going wrong, I would just create another text object, and enter '= vCurrentLabel', then click on your Oxxio picture and see if it shows the value you are expecting.

Also, I think there are some extra brackets you don't need in your vKleur1 variable, I'm not sure if this is affecting it, but try this:

= if ( vCurrentLabel = 'Eneco Consumenten B.V.' , RGB(210,18,66), 

   if ( vCurrentLabel = 'Oxxio', RGB(0,122,156), 

   if ( vCurrentLabel = 'WoonEnergie', RGB(209,221,27), 

RGB(236,116,15) )));

Not applicable
Author

Hi Gysbert,

I forgot to add the file. I uploaded it now... Does this help?

Cheers,

Marc

Gysbert_Wassenaar

There's no field LABEL in the document you posted. I've used the field Netbeheerder instead.


talk is cheap, supply exceeds demand