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

colouring 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 achieved this 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 image.

azucna122_0-1674812990079.png

 

1 Solution

Accepted Solutions
rubenmarin

If ther eare 2 different measures, one positive and one negative, you can create a master item for each and assign the measure color in the master item, then on chart use the master items as measures and select the option to use library colors on Layout -> presentation ->colors and legend

View solution in original post

6 Replies
rubenmarin

Hi, I don't know why you use the fabs, have you tried this?:

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

Or just: = if(count(product) > 0, green(), red())

azucna122
Partner - Creator
Partner - Creator
Author

Hello Ruben, 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.

vinieme12
Champion III
Champion III

can you post the Chart Expression instead?

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
rubenmarin

If count(product) is higher than zero it will go with the first condition and there will be only green bars or zero bars, so something else is creating that negative bars. Use the same expression that gives values to the bars to color the bars.

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.

rubenmarin

If ther eare 2 different measures, one positive and one negative, you can create a master item for each and assign the measure color in the master item, then on chart use the master items as measures and select the option to use library colors on Layout -> presentation ->colors and legend