Creating a HEX function for use in expressions

Creating a HEX function for use in expressions

We must define colors in HEX for themes, and color pickers etc., but we must use RGB etc. in expressions.

It would really simplify things if we could have a HEX function that allows us to input the HEX value and render the color e.g., currently, our expression might look like this:

if([Utilisation Rate]<0.9,red(),green())

After going to all the trouble of defining our style palette in a theme, it would be great if we could do:

if([Utilisation Rate]<0.9,hex(‘d73b56’),hex(‘008e85’))

Converting RB decimal values to HEXA color codes (for instance for dynamic coloring in P&L Pivot Extension from Qlik™).

While answering to some requests of a client in delivering the best possible P&L visualization, we  married the Qlik™ P&L Pivot Extension with our QQfin engines.

One of the challenges we had was to create a formula that reuses a dynamic set of R,G,B values for conditional coloring  in the pivot. Started with the help here, but we were capable of only partially at, despite the statements.

Mathematical background for the digitally confused ones
ABC (10) = A * 10^2 + B * 10 + C
               where A, B, C are between 0 and 9
                              B = 10 => biggest figure is 10-1 = 9

or

ABCDE (10) =  A * 10^4 + B * 10^3 + C * 10^2 + D * 10 + E
Similarly
ABC (16) = A * 16^2 + B * 16 + C
               where A, B, C are between 0 and 9
                              B = 16 => biggest figure is 10-1 = 15
                              notation convention for 16 bases for figures bigger than 9 are:
                                            10 = a
                                            11 = b
                                            15 = f
Solution
= ‘#’ & if(Rvalue<16,’0′,”) & num (Rvalue*256*256 + Gvalue * 256 + BValue * , ‘(HEX)’ )

For information about Qlik™, please visit this site: qlik.com.

For specific and specialized solutions from QQinfo, please visit this page: QQsolutions.

In order to be in touch with the latest news in the field, unique solutions explained, but also with our personal perspectives regarding the world of management, data and analytics, we recommend the QQblog !