Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Null condition in color expression

Hi, I have two measures, Test and Compare. I want to change the color of my chart based on whether Test>Compare or not. However there are some null values in Test.

My expression if(sum(Test)>sum(Compare),red(),green()) does not work because of the null values in Test. Is there a way to add the null condition into my if statement?

Thanks.

11 Replies
sunny_talwar

You may be able to something like this?

If(Len(Trim(Sum(Test))) = 0, Blue(), If(Sum(Test) > Sum(Compare), Red(), Green())

Best,

Sunny

MK_QSL
MVP
MVP

what is dimension and expressions in your chart?

Not applicable
Author

Test and Compare are both measures in my chart. Name is the dimension.

Not applicable
Author

Hi Sunny I tried this but it did not work...

sunny_talwar

Can you share a sample or show screenshots?

MK_QSL
MVP
MVP

You mean to say...

Dimension

Name

Expression

SUM or COUNT or some function (Test)

and SUM(Compare)

You want to change color of both chart?

kindly clarify on this!

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

‌nulls should be treated as zero by sum(). What happens if you put sum(Test) in a text object?

Rob

Not applicable
Author

Use the Visual Cues option in the Chart.

Not applicable
Author

Hi Manish, it is just one chart. Sum(Test) and Sum(Compare) are measures of the chart and Name is the dimension. It is a scatterplot. I want to change the color that when Sum(Test)>Sum(Compare), show me red, and otherwise green. There are null values in Test that is messing up the condition. Thanks.