Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to define colours in load statement?

Hi all,

I have defined a palatte of nine colours which I want to use in a bar chart.

I added the following lines in my "Main" Data Editor sheet:

SET kBlue = ‘=rgb(77,119,171)';

SET kBlueLight = ‘=rgb(55,164,208)';

SET kBlueDark = ‘=rgb(47, 48, 82)';

SET kPurple = ‘=rgb(98, 52, 127)';

SET kGrey = ‘=rgb(96, 96, 92)';

SET kGeen = ‘=rgb(78, 175, 69)';

SET kYellow = ‘=rgb(245, 187, 37)';

SET kRed = ‘=rgb(217, 34, 64)';

SET kBlack = ‘=rgb(3, 3, 3)';



Now, if I want to use the "colour by expression" function on my bar chart and type the following:

IF(Sum([Diff x Amount])/Sum([Amount in Euro])<20,kRed,

  if(Sum([Diff x Amount])/Sum([Amount in Euro])<30, kYellow,

      if(Sum([Diff x Amount])/Sum([Amount in Euro])<40, kGreen,

      if(Sum([Diff x Amount])/Sum([Amount in Euro])<50, kYellow,

       kRed

   ))))

QlikSense throws an "invalid field name" error. If I replace the bold colours with "standard colours" like red() it works.

What am I doing wrong?

Thanks!

ps. side note:

Is it possible to use master measures in expressions?

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

If you use variables that start with an equals sign, and dollar expansions, they will be recalculated every time you click. This is unnecessary. Instead, you could use numerical values of the colors. So, use a Let statement instead of a Set statement:

     Let kBlue = Num(rgb(77,119,171));

Then your expression will work.

HIC

View solution in original post

4 Replies
pokassov
Specialist
Specialist

Hi!

kRed  -> $(kRed)

hic
Former Employee
Former Employee

If you use variables that start with an equals sign, and dollar expansions, they will be recalculated every time you click. This is unnecessary. Instead, you could use numerical values of the colors. So, use a Let statement instead of a Set statement:

     Let kBlue = Num(rgb(77,119,171));

Then your expression will work.

HIC

Not applicable
Author

thanks guys

Not applicable
Author

Use LEt and Num ie....

LET kBlue = Num(rgb(77,119,171));

LET kBlueLight = Num(rgb(55,164,208))';

LET kBlueDark = Num(rgb(47, 48, 82))';

LET kPurple = Num(rgb(98, 52, 127));

LET kGrey = Num(rgb(96, 96, 92));

LET kGeen = Num(rgb(78, 175, 69));

LET kYellow = Num(rgb(245, 187, 37));

LET kRed = Num(rgb(217, 34, 64));

LET kBlack = Num(rgb(3, 3, 3));