Heat maps are a common requirement in most of the BI implementations. A Colormix1
function helps to create a gradient between two colors. Look at the following recipe to understand the use of this function.
We will make use of a simple Inline load for this recipe. Perform the following steps to get started:
HeatMaps_Colormix1
.Actuals
and Budget
for products:Products: LOAD * INLINE [ Product, Actuals, Budget Footwear, 100000, 120000 Tyres, 180000, 150000 Mountain Bikes, 250000, 195000 Road Bikes, 200000, 225000 Chains, 80000, 90000 Helmets, 240000,160001 Gloves, 56000,125000 Pedals, 45000,100000 Rucksacks, 300000,450000 ];
Actuals
.colormix1(sum(Actuals) / $(=max(aggr(sum(Actuals), Product))), white(), RGB(0, 70, 140))
The
colormix1
function creates a gradient between two colors using a number that varies from 0
to 1
.
We know that the bar for the product with the highest value of Actuals
will be the most intense. So to achieve a value between 0
and 1
, we calculate the relative shares of each actual value against the highest actual value from the entire product range. That is "Actuals for each product"/"The highest Actuals value from the entire product range".
In our expression, the Colormix1
function helps to establish a gradient from white to RGB (0, 70, 140)
.
A sequential color gradient across the chart can be obtained through the chart properties if we select the color by measure. However, we can't have custom colors if we use this approach and we will have to depend on the color scheme in Qlik Sense.