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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Qlik Sense - Custom measure colours with expression

I am still new to qlik sense.

I am trying to set custom colours for a stacked bar chart, where each category in a measure is a different colour.

I have trawled through the community board and found no solution that worked for me. I am not at the discretion of adding extra instructions into the load data as this request is for a once off report and there are business caveats atm.

The measure is a "status", with the categories being:

Approved = Green

Cancelled = black

In progress = cyan

Rejected = magenta

Returned = yellow

Incomplete = blue

This is the expression I have been playing with, but qlik continues to say "error in expression". everything is displaying in a green colour in the expression except the "if" part, which is blue.

I'm normally ok with formulas having worked in excel quite a bit. Where are am I going wrong? I'm sure it's something simple.

if([PR-Authorization Status]='Approved',([alpha,0,128,0]),if([PR-Authorization Status]='Cancelled',([alpha,0,0,0]),if([PR-Authorization Status]='In progress',([alpha,0,128,128]),if([PR-Authorization Status]='Rejected',([alpha,255,255,0]),if([PR-Authorization Status]='Returned',([alpha,255,0,255]),if([PR-Authorization Status]='Incomplete',([alpha,0,0,128])))))))

 

Labels (1)
6 Replies
PriyankaShivhare
Creator II
Creator II

the color code format should be argb(175,242,0,0) or RGB(0,0,0) or '#000000'

Hope this helps!
Thanks,
Priyanka
Anonymous
Not applicable
Author

Thanks for the reply.

I have adjusted the expression:

if([PR-Authorization Status]='Approved',rgb([0,128,0]),if([PR-Authorization Status]='Cancelled',rgb([0,0,0]),if([PR-Authorization Status]='In progress',rgb([0,128,128]),if([PR-Authorization Status]='Rejected',rgb([255,255,0]),if([PR-Authorization Status]='Returned',rgb([255,0,255]),if([PR-Authorization Status]='Incomplete',rgb([0,0,128])))))))

And I'm now getting a "RGB takes 3 parameters" message from Qlik, but I've got the "rgb(X,X,X)"  expression listed?

Any further assistance would be appreciated >_<

Anonymous
Not applicable
Author

I have managed to fix the expression by removing the "rgb' statement and using a basic colour function instead.

if([PR - Authorization Status]='APPROVED','purple',If([PR - Authorization Status]='IN PROCESS','blue',if([PR - Authorization Status]='CANCELLED','green',if([PR - Authorization Status]='INCOMPLETE','yellow',if([PR - Authorization Status]='REJECTED','red',if([PR - Authorization Status]='RETURNED','black','gray'))))))

PriyankaShivhare
Creator II
Creator II

u need to remove the square brackets in rgb value:

if([PR-Authorization Status]='Approved',rgb(0,128,0),if([PR-Authorization Status]='Cancelled',rgb(0,0,0),if([PR-Authorization Status]='In progress',rgb(0,128,128),if([PR-Authorization Status]='Rejected',rgb(255,255,0),if([PR-Authorization Status]='Returned',rgb(255,0,255),if([PR-Authorization Status]='Incomplete',rgb(0,0,128)))))))

 

Thanks,

Priyanka

PradeepK
Creator II
Creator II

Not sure if you know about Master dimension - Value colors option.

Dimension value colors remains consistent through out the application.. you do not have to write complex expression with nested if conditions. 

MasterDim - value color.png

Color Stack Barchart.PNG

 

Anonymous
Not applicable
Author

As this is for a once off report from a dataset that is accessed by many business users, I have opted for a once off expression instead of changing the master dimension. I have suggested moving forward if this request continues to be on-going then we can look at this option. It is by far the simpler choice.

Thanks for your input 🙂