Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Shady
Contributor
Contributor

Set color of chart based on field value

I have the below dataset:

FileName                           Days

abc                                        1

def                                         2

ghi                                          0

 

I am trying to display these in a bar chart with the below logic:

if(Days = 1,yellow(),if(Days = 0, green(),red())) - this expression I have used in Appearances -. Colors -> by expression. I have the "Expression is a color code" checkbox checked too.

But I always get all the bars in yellow as thats the value for the first row.

Any help would be greatly appreciated.

Labels (1)
1 Solution

Accepted Solutions
Lisa_P
Employee
Employee

What is your expression in Expressions tab?

If you are using Sum(Days), then you would also need to use this in your color expression.

Expand expression, select Background color and try this expression:
if(Sum(Days 0= 1,yellow(),if(Sum(Days )= 0, green(),red())) 

View solution in original post

1 Reply
Lisa_P
Employee
Employee

What is your expression in Expressions tab?

If you are using Sum(Days), then you would also need to use this in your color expression.

Expand expression, select Background color and try this expression:
if(Sum(Days 0= 1,yellow(),if(Sum(Days )= 0, green(),red()))