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

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

Creating a condition to change the color background of a chart

Hello everyone,

I am trying to create a condition which alternate the color background, depending the value of the field.

Basically, the background should be RED if the value is negative (< 0), and should be GREEN if the value is positive (> 0).

Suposing that my field is "balance", i tryed to use the following expression:

if([Balance] > 0, Green(), Red())

But my chart is displaying always the Red Color, even if the value of Balance is positive.

Someone could help to fix that?

Regards,

1 Solution

Accepted Solutions
sunny_talwar

May be there are more than one Balance for each row? May be try Sum([Balance]) or Avg([Balance]) or some other aggregation in your expression?

If(Sum([Balance]) > 0, Green(), Red())

View solution in original post

7 Replies
sunny_talwar

May be there are more than one Balance for each row? May be try Sum([Balance]) or Avg([Balance]) or some other aggregation in your expression?

If(Sum([Balance]) > 0, Green(), Red())

satishkurra
Specialist II
Specialist II

Everything looks OK to me,

Let me ask you this

Hope you are writing the above mentioned expression in Expressions Tab?

It doesn't even matter where you are writing.

It would be great if u can share a sample app..

rudolfhbantim
Contributor II
Contributor II

Do you have a column with the same name of your field? Maybe this is a problem.

Not applicable
Author


I hae many values in the field Balance, i am doing sum of all the values of this column:

Sum(Balance)

consenit
Partner - Creator II
Partner - Creator II

Hi there.

As a rule of thumb you should always use aggregation functions instead of field references in chart expressions:

Use Aggregation Functions!

Kind regards,

Ernesto.

Not applicable
Author

Thanks Sunny,

It was missing the sum statement, now it is ok!

sunny_talwar

Awesome