Qlik Community

Qlik Design Blog

All about product and Qlik solutions: scripting, data modeling, visual design, extensions, best practices, etc.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Now
Employee
Employee

There are many different areas in QlikView where the developer can define a specific color to be used. Most times developers will simply navigate to the color picker and select the color that is closest to the color that they are looking for.

QlikView also offers the user ways to define what the color should be based on the result of an expression. This gives the developer the ability to change the color at will. QlikView also gives the developer the ability to define the opaqueness of a specified color as well. This is particularly useful when scatter chart coordinates fall within the same intersection. The two functions that I want to talk about are RGB() and ARGB().

To show the RGB() and ARGB() functions in action I will run through a couple of examples from the Pharma Sales Demo on demo.qlik.com.

Scenario 1 – Coloring the background in a table based on an expression result using RGB()

PharmaSales1.png

On the Expressions tab within the Object Properties, we are going to create the expression in the Background Color area that will prompt QlikView to set the background color of the Quarter cells.

PharmaSales4.png

We need to fill the background color with green if the quarter is greater than the previous quarter, to fill the background with yellow if the quarter is equal to the previous quarter and fill the background with red if the quarter is lower than the previous quarter.

The expression looks like this:

If([Q2]>[Q1], rgb(108,179,63),

If([Q2]=[Q1], yellow(),

If([Q2]<[Q1], rgb(255,110,110))))

Because we are filling the background with a specific color based solely on the result of the calculation, we used the RGB() function.

Scenario 2 – Specify the colors of data points on a scatter chart based on an expression using ARGB()

In this chart we will use ARGB() to show multiple plot points on a scatter chart that are placed on top of each other.

PharmaSales5.png

If we used RGB() in this chart, we would not be able to see the different levels of the same color on one plot point.

PharmaSales6.png

The requirement is to fill the background and the text color as follows:

Must Call = Red

Need To Call = Yellow

Recent Call = Green

Not Targeted = Grey

The expression looks like this:

if([Call Priority]='Must Call', argb(175,242,0,0),

if([Call Priority]='Need To Call',argb(175,254,197,80),

if([Call Priority]='Recent Call', argb(175,111,176,29),

if([Call Priority]='Not Targeted',argb(175,190,190,190) ))))

The expression result shows how the opaqueness allows the user to see multiple intersecting plot points, helping the user to get a clearer picture of all of the data points. As is shown above, without the opaqueness, the green plots on the plot of 1 would look like a solid green dot instead of showing that there is more than one plot point.

We can also use the ARGB() function with maps as well. Using the same expression as above we can see how the opaqueness allows the user to see multiple intersecting plot points as well as original map data such as city names, street names, etc.

PharmaSales7.png

   

In conclusion, if you want to specify the color of your backgrounds, text colors, data points, etc, you can with QlikView. The take away from this should be to think before you color.  If you are coloring a background or text, use RGB(). If you are coloring data points on a scatter chart and some or many of the data points will overlap, you may want to consider ARGB(). I wrote a technical paper about this that goes into a little more detail. You can find it here.

Happy Qliking!!

9 Comments
Not applicable

thanks for useful post

0 Likes
2,121 Views
MVP
MVP

one of many different ways of coloring.... Good work done

0 Likes
2,121 Views
Creator II
Creator II

Thanks Charles:

A principal idea in the field of BI - Color & Coloring. Great post.


0 Likes
2,121 Views
Creator
Creator

HI Charles,

This is very useful post, as i am integrating this function in my application ..

Thanks for the heads up.

Cheers,

Sandeep.

0 Likes
2,121 Views
Not applicable

Hi Charles

I have used same method to change bgcolor of  cells in pivot table.
Issue is Expression headings are also getting colored.

Can you please help ?

0 Likes
2,121 Views
Not applicable

Thanks, it works for me

0 Likes
2,121 Views