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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now

Gradient color palette with the ColorMix2() function

cancel
Showing results for 
Search instead for 
Did you mean: 
MatheusC
Specialist II
Specialist II

Gradient color palette with the ColorMix2() function

Last Update:

Dec 28, 2023 8:54:39 AM

Updated By:

MatheusC

Created date:

Dec 28, 2023 8:56:08 AM

Attachments

Hi qlik community members, 👋

Check out this solution to create your own gradient color palette with the ColorMix2() function.

Resolution in stages

Let's see how we can achieve this result, in a simple data model.

1 – Find the largest and smallest value of your measurement.

max(total aggr(Sum([Total value]),Customer))

min(total aggr(Sum([Total value]),Customer))

 2 – Calculate the difference between these values

max(total aggr(Sum([Total value]),Customer))
-
min(total aggr(Sum([Total value]),Customer))

3 – Now we will create a range, where we will identify positions 0 and 1 of the indices, or basically the values ​​from 0% to 100%.

(sum([Total amount])
-
min(total aggr(Sum([Total amount]),Customer)))

/

(max(total aggr(Sum([Total amount]),Customer))
-
min(total aggr(Sum([Total amount]),Customer)))


4 – To apply the gradient, in your graph go to the Presentation window -> Colors and Legend -> Colors Customize by expression. In the check box, leave the option selected as shown below:

MatheusC_0-1703769149372.png

 

5 – Finally, in the expression insert your calculation within the ColorMix2() function. 

ColorMix2((sum([Total amount])
      -
min(total aggr(Sum([Total amount]),Customer)))

/
(max(total aggr(Sum([Total amount]),Customer))
-
min(total aggr(Sum([Total amount]),Customer))),red(),blue(),yellow())


For more details see this and other color functions in the qlik help. 

https://help.qlik.com/en-US/sense/November2023/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/Color...

I hope you like it! 🙂

Attached is the qvf for anyone who wants to see the example model exposed.

Yours sincerely, Matheus

Comments
JoãoPolloni
Contributor III
Contributor III

Thank you  @MatheusC  for the insightful article! It's been a treasure trove of layout ideas.

HnLima
Contributor II
Contributor II

@MatheusC 
Congratulations! on your article

Contributors
Version history
Last update:
‎2023-12-28 08:54 AM
Updated by: