# New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Action-Packed Learning Awaits! QlikWorld 2023. April 17 - 20 in Las Vegas: REGISTER NOW
cancel
Showing results for
Did you mean:
Partner - Contributor III

## colour a negative value that is positive in red

Hi I am new to qlik, i am trying to make a graph that represents negative and positive values, I have succeeded with the expression:
= if(count(product) > 0, green(),
if(Fabs(count(product) > 0) * -1, red())))

My problem is that I don't know how to paint the negative values, since they are not negative values as such, because I have forced them with the Fabs() *-1 function.
Does anyone know how to colour those positive values converted to negative values? as shown in the img

Labels (8)

• ### Visualization

1 Solution

Accepted Solutions
Partner - Master II

If you've got 2 measures and one dimension.

Make the measures master items and set the colour for them the chart will take care of the rest on Auto.

10 Replies
Specialist

Hi, what if you paint your positive values green and all other red without additional IF? Like:

if(count(product) > 0, green(), red())

Partner - Contributor III
Author

I was using Fabs, because I don't have negative values, I convert positive values into negative, that's why I can't use those 'false negatives' when colouring the < 0, because they are not really less than 0, but a multiplication by -1.

Specialist

Then I don't quite understand why you make a negative value out of the count() function. Maybe you can provide little sample of data you are using? Because, count(product) always provide positive result (as it is counting number of rows of your product), fabs basically convert true clause to number, *-1, so with expression

= if(count(product) > 0, green(), if(Fabs(count(product) > 0) * -1, red())))

you paint positive values green and again, same values you try to paint red. But as first if() is true, your all graphs should be green? Or not?

Partner - Contributor III
Author

I am using two measures, one for positive values: count(if(product >0,customers))
for negative values, its measure is: Fabs(count(if(product<0,customers))) *-1
In this expression I convert the positive values in negative, I have tried to put the same expressions in the colour section, but it paints everything in green because it detects that they are all positive, when I force the negatives I don't know how to make it detect the 'false negatives' and paint them in red.

Specialist

and your dimension 'product' is number?

Partner - Contributor III
Author

yes, is number

Specialist

then maybe it is better to use sum() instead of count()? And suggestion (for color, not for calculation of customers) if(sum(product) > 0, green(), red()) should work I guess

Partner - Master II

If you've got 2 measures and one dimension.

Make the measures master items and set the colour for them the chart will take care of the rest on Auto.

Partner - Contributor III
Author

thank you very much, it was just what I needed!!

Tags
Community Browser