Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Change background cell color in the chart table

I have an expression to change background color of a cell on

=If([Technology Status]='AAA',lightgreen()) -

works fine but I do have multiple statuses so I want to color them in different colors.

Such as:

=If([Technology Status]='XYZ',lightblue()) and

=If([Technology Status]='xxx',red()) and so on

How do I use nested if or is there any better way? Thanks, yury

1 Solution

Accepted Solutions
googel84
Partner - Creator III
Partner - Creator III

Hi ypritzke, look at my piece of code. It works fine to me.

if( Status = 'Completed',
green(),
if( Status = 'Completed with warning',
yellow(),
if( Status = 'Completed with errors',
red(),
if( Status = 'Not planned',
RGB(255,100,0),// arancione
if( Status = 'Not started',
red(),
white()
)
)
)
)
)

View solution in original post

11 Replies
Not applicable
Author

I don't have access to QV at the moment but dont forget how the 'if' statement is constructed:

if (conditional statement, true, false)

so you nest an if like:

If([Technology Status]='AAA',lightgreen(), If([Technology Status]='XYZ',lightblue(), if (......)))

Regards,

Gordon

Not applicable
Author

I tried this, does not work, even the first if stoped working.

tabletuner
Creator III
Creator III

are you sure you wrote the expression in the expanded part of the expression (push the '+') called 'Background color'?

Just writing this in the normal expression wont work.

Not applicable
Author

Yes, it is an expression of a Background color

googel84
Partner - Creator III
Partner - Creator III

Hi ypritzke, look at my piece of code. It works fine to me.

if( Status = 'Completed',
green(),
if( Status = 'Completed with warning',
yellow(),
if( Status = 'Completed with errors',
red(),
if( Status = 'Not planned',
RGB(255,100,0),// arancione
if( Status = 'Not started',
red(),
white()
)
)
)
)
)
Not applicable
Author

Thank you. it worked. I did not have very last altrenative like white() in your case

Not applicable
Author

Well done. I liked it.


ERP Consulting
SAP ERP Consultants

johnw
Champion III
Champion III

Another option:

pick(match("Technology Status",'AAA' ,'XYZ' ,'xxx',...)
lightgreen(),lightblue(),red(),...)

And another:

StatusColors:
LOAD * INLINE [
Technology Status,R,G,B
AAA,50,255,50
XYZ,50,50,255
xxx,200,0,0
...
];

rgb(R,G,B)

quiquehm
Contributor III
Contributor III

Hi John,

I am interested in your inline table for background coloring. I have a large table of activities which need to have a different color for every activity ( fixed colors by activities ), and using nested if in the expression causes the app to run very very slow . I guess your solution of the inline table in the script will make the app to run better. What expression do you enter for the background color ? just this one ?: =RGB(R,G,B) ?

THANKS