QlikView: Quick tip #2 - Fixed colors in charts

Let say that you are building a dashboard to analize data from a helpdesk system, and you have been requested to add a chart that shows the total of open cases by category (low, medium, high, and emergency). You create the chart, and everything looks fine except for the fact that when you start filtering the data you notice that the colors assigned to each category are not always the same (check the image below, if data is filtered to show only January tickets high is in red color, but if February is selected high is displayed in blue). In this quick tip we explain how to avoid this situation, and keep the color assigned to each posible value in a dimension fixed.



To set the background colors in a chart go to Chart Properties --> Expressions. Next, click on the plus sign next to name of your expression.


A list of options will appear under the expression label. Select Background color.


In the text area under definition, you can add an expresion to set the backgroun color. In this example we have used an expresion like the following one:


But, what does this expression do? Well, the match function compares the value in the Category field with the ones in the list and returns the number of the position that matches. Then this value is taken by the pick function which returns the expresion in the position indicated. For instance, if current Category value is equal to "Emergency", match function will return 4, and Pick will return the expression RGB(249, 70, 84).

Here is the result of applying an expression to set the background color, now if the cases are filtered to display only January data, high is shown in dark blue. If a different month is selected, high keeps the same color.



You can download this example here.



No comments:

Post a Comment