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: 
azucna122
Partner - Creator
Partner - Creator

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

 

azucna122_0-1674812140280.png

 

1 Solution

Accepted Solutions
ogster1974
Partner - Master II
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.

ogster1974_1-1675070480001.png

 

ogster1974_0-1675070437963.png

 

View solution in original post

10 Replies
justISO
Specialist
Specialist

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

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

azucna122
Partner - Creator
Partner - Creator
Author

Hello justISO, thank you for your reply.
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.

justISO
Specialist
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?

azucna122
Partner - Creator
Partner - Creator
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.

justISO
Specialist
Specialist

and your dimension 'product' is number?

azucna122
Partner - Creator
Partner - Creator
Author

yes, is number

justISO
Specialist
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

ogster1974
Partner - Master II
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.

ogster1974_1-1675070480001.png

 

ogster1974_0-1675070437963.png

 

azucna122
Partner - Creator
Partner - Creator
Author

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