Colour functions are used to colour measures or dimensions in visualisations.

This article will cover the basic principles of working with colour functions in visualisations, including:

  • The general function syntax
  • Working with colour functions in visualisations

For a complete, up-to-date list of colour functions, please see the Qlik Sense help pages here.

The colour function syntax

The general function syntax varies depending on the function. In this section, we will use an example function and decipher its syntax. This understanding will then help you read the syntax of other functions.

Example: RGB

The RGB() function returns a colour code based on the input of integer components specifying the red, green and blue values.

The rules for reading the function syntax are as follows:

  1. The function name itself is first and all the parameters you need to enter go between brackets: ().
  2. The various elements you will need to enter are separated by commas. In this function, the elements to enter are red value, green value and blue value.
  3. Anything between square brackets [] is an optional parameter. In this function, there are no optional parameters.

An example of this function being used would be:

How to use colour functions in visualisations

Here are some important points on using colour functions in visualisations:

  • All functions can be used within the expression editor area to specify a specific dimension or measure colour.
  • The functions can be nested and combined with other types of functions.

Here is an example of using the RGB function to specify dimension colour based on the value. In the bar chart properties under appearance > colors and legend > custom color > by expression, we enter this expression:

If(WildMatch([Customer Name],'* Ltd*'), RGB(255,0,127), RGB(102,204,0))

As a result, any customers with ‘Ltd’ in the name are coloured pink while other customers are coloured green.