
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using colormix2 function with defined values for switching the color
Hi experts!
I am working on a straight table with multiple dimensions and metrics. One of the metrics is ROAS which is basically revenue/cost presented in %. For a quick overview my managers want me to apply a color gradient with the following settings: <15% - red (the lower the percentage, the redder the cell), 15%-50% - yellow (the higher the percentage the closer to green we get), > 50% - green (the closer to 100% the darker the green.
I have tried using the colormix2 function colormix2(rank(total Column(20))/NoOfRows(total),RGB(0, 255, 0), RGB(255, 0, 0), RGB(255, 255, 0)), but got confused about where the numbers defining the gradient need to be set.
Could anybody advise me on this question?
- Tags:
- colormix
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Resolved this in this way in the end 🙂 if([target measure]< 0.15, ColorMix1(rank(total Column(23))/NoOfRows(total),yellow(), red()),
if([target measure] >= 0.15 AND [target measure] < 0.3,
ColorMix1(rank(total Column(23))/NoOfRows(total),green(), yellow()),green())).


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The first parameter of the ColorMix2() function is what sets the position on the gradient. The following two define the gradient's endpoints. A third would set the color for the midpoint (gradient position = 0).
You might want to have a look at sample apps such as this one:
https://community.qlik.com/t5/Member-Articles/Color-Themes-with-ColorMix-qvf/ta-p/1486684
Note that in your case you would presumably need to use multiple ColorMix functions with an if() statement determining which of them to use. You might also want to use endpoints that are not 255-based to smooth out the transitions.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the quick response! I saw multiple examples of using colormix and colormix2 functions but all of them were centred around using the gradient from the largest to the lowest value in e.g. row or column, hence the usage of rank(total Column(20))/NoOfRows(total). But for now it seems that to set the values myself (that for e.g. yellow the switch happened at 15%) I need to use multiple if and colormix statements 😞 instead of one.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is correct - the function is intended to create a single gradient, not multiple unrelated gradients. Nothing that can't be solved with a few if() statements, though.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Resolved this in this way in the end 🙂 if([target measure]< 0.15, ColorMix1(rank(total Column(23))/NoOfRows(total),yellow(), red()),
if([target measure] >= 0.15 AND [target measure] < 0.3,
ColorMix1(rank(total Column(23))/NoOfRows(total),green(), yellow()),green())).
