English Qlik

Change colors in Qlik using variables

—————————————————————————————

Hi! Please tell me what kind of Qlik content you think is relevant or interesting to have in the channel (use the link below). Thanks!

Link: https://approbato.com/blog/quick-qlik-survey/

—————————————————————————————

 

In this video/post I describe two ways to dynamically change the colors of your visuals in Qlik Sense.

Click here to download the QVF created in the video.

The first one is quite simple:
Qlik uses the RGB color scheme, so we can color the visuals by expression using the RGB() function. Inside the function it we use the variables to change the colors.
In the video I create three variables (one for each color – R for Red, G for Green and B for Blue), and set the values to be between 0 and 255.
With that we use a slider changing these variables, and in the charts we use the following expression to use the desired color: RGB ( $(R) , $(G) , $(B) ) – Use the Dollar sign + Parenthesis to call the variables.

The second way in the video is by using a “Color table”, in which we have rgb codes for a rank/number of options, and we call these codes as texts using variables and set analysis (for instance:

Only( {<Color={‘Red’},SortColor={‘1’}>} ColorCode) .

The Color table used in the example was this one:

ColorSortColorColorCode
Red1rgb(243, 207, 204)
Red2rgb(231, 158, 153)
Red3rgb(220, 110, 102)
Red4rgb(208, 61, 51)
Red5rgb(138, 4, 0)
Green1rgb(204,244,211)
Green2rgb(153,233,166)
Green3rgb(107,197,122)
Green4rgb(8,158,33)
Green5rgb(0,125,21)
Yellow1rgb(245, 236, 204)
Yellow2rgb(235, 217, 153)
Yellow3rgb(225, 199, 102)
Yellow4rgb(215, 180, 51)
Yellow5rgb(205, 161, 0)
Blue 1 rgb(204, 205, 243)
Blue 2 rgb(153, 154, 231)
Blue 3 rgb(51, 53, 208)
Blue 4 rgb(3, 6, 161)
Blue 5 rgb(0, 2, 115)

There are many other ways and possibilities, but I hope you find it useful.

Leave a Reply

Your email address will not be published.