Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Parametric variable

Hello,

I'd like to set the background color of a cell by means of a parametric variable.

My variables are:

ClasseA = RGB (128,255,128)

ClasseB = RGB(255,255,128)

The field ClassComp can have the values of A and B and I'd like to set its background color using the variable ClasseA (when the ClasseComp value is 'A') and the variable ClasseB when the ClasseComp value is 'B'

How can I set the background value using the variables ClasseA and ClasseB parametrically?

I've tried with =$(Classe & ClasseComp) but it doesn't work...

Obviously in this example I used only A and B, but my classes are from A to Z, so I dont't like to use 26 nested if.

Thank you.

N.

1 Solution

Accepted Solutions
alex_millan
Creator III
Creator III

Hi,

perhaps an inline load in the script would help you?

For example:

A:

LOAD * INLINE [

Class, Red, Green, Blue

A, 128, 255, 128

B, 255, 255, 128

C, 120, 120, 120

];

Then, you can set the colour:

RGB(Red, Green, Blue)

Regards

View solution in original post

7 Replies
alex_millan
Creator III
Creator III

Hi,

perhaps an inline load in the script would help you?

For example:

A:

LOAD * INLINE [

Class, Red, Green, Blue

A, 128, 255, 128

B, 255, 255, 128

C, 120, 120, 120

];

Then, you can set the colour:

RGB(Red, Green, Blue)

Regards

Anonymous
Not applicable
Author

I defined vClass = 'Class'

and vClassA = rgb(128,255,128)

and vClassB = rgb(255,255,128)

and vComp = A

Then I can use

=$(=$(vClass)&vComp)

in the Background of Expression and it gets me the Color

Instead of variable vComp it should be your field with values A to Z

Anonymous
Not applicable
Author

Well...I'm in trouble with the syntax by using the fields:

=$(=$(vClasse)&ClasseComp)

returns only the value 'Classe' (the value of the variable vClasse)

Would you mind to post the right syntax?

Thanks.

N.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Does it work if you put a listbox with field ClasseComp on the sheet, and select a single value in the listbox?

Anonymous
Not applicable
Author

Sorry, I didnot get it work with a field

I suppose that the Problem that the Expression is calculated only once

using an Aggregation function or select a value makes it work

also using If Statement (IF ClassComp='A' etc. makes it work

But with fields which can contain more than 1 value , I didnot get it work

Peter_Cammaert
Partner - Champion III
Partner - Champion III

So the solution that Alex presented would fix the problem with dynamic coloring in tables. Just change the colors in his INLINE table, and rename column Class to ClassComp.

Then add an expression =rgb(Red, Blue, Green) to every cell that needs coloring and that belongs to a row with a single ClassComp value.

Anonymous
Not applicable
Author

Thank you so much for the solution, and thanks also to everybody for the help.

N.