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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Peony
Creator III
Creator III

How to use colormix2 if lowest number is 0

Hi all.
Could someone please advise how to adjust the Rank part for colormix2 () to have a gradient starting from 0, not -1? In this case, 0 is the smallest possible number and should be perceived by the function as -1, that is, be in red.

I don't use colormix1 because colours from red to green should go through white colour. 


My current results and expression. 

=Colormix2 ((Rank(total Sum (Velocity_Sales)))/(NoOfRows(Total)/2), Red(), Green(), white())



Peony_0-1742587380600.png

 

Labels (3)
1 Solution

Accepted Solutions
rubenmarin1

Hi, the default formula to convert values to another range is:

(value - min_value) / (max_value - min_value) * (max_range_value - min_range_value) + min_range_value

For a -1 to 1 range it's the same as:

((value - min_value) / (max_value - min_value) * 2) - 1

If you set a predefined range where all values below that range is red, and above is green, it simplifies a lot the calculation, as min_value and max_value will be converted to that fixed numbers.

If you want to get the max a min values you have as the range, the you need to calculated them first to apply them on the formula, just note that in that case, selections can change colors, one value could be white, but if selections changes the values shown, that white could be converted to red or green depending on the new values filtered.

You can also calculate the min and max values on script, and set those values in variables, so you can use them as fixed values.

View solution in original post

2 Replies
rubenmarin1

Hi, the default formula to convert values to another range is:

(value - min_value) / (max_value - min_value) * (max_range_value - min_range_value) + min_range_value

For a -1 to 1 range it's the same as:

((value - min_value) / (max_value - min_value) * 2) - 1

If you set a predefined range where all values below that range is red, and above is green, it simplifies a lot the calculation, as min_value and max_value will be converted to that fixed numbers.

If you want to get the max a min values you have as the range, the you need to calculated them first to apply them on the formula, just note that in that case, selections can change colors, one value could be white, but if selections changes the values shown, that white could be converted to red or green depending on the new values filtered.

You can also calculate the min and max values on script, and set those values in variables, so you can use them as fixed values.

Peony
Creator III
Creator III
Author

@rubenmarin1 thank you much