Relational functions return information about the calculated data point relative to other values.

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

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

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

The relational 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: Rank

The Rank() function returns the ranking of a given value against other values.

Rank([TOTAL] expr[, mode[, fmt]])

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:
    • [TOTAL] -> this is an optional function qualifier. If used, it ignores dimensions in the table.
    • expr -> the field or expression containing values you want to rank.
    • [mode] -> specifies how the result is returned as a number representation. By default, it is 0. If you use 1, Qlik will return the lowest rank on all rows, 2 will return the average rank, 3 will be return the highest, and 4 is the lowest rank on the first row, which is then incremented on each row.
    • [fmt] -> as [mode] but for text representation. Applicable values are 0 (default), which is a low to high rank on all values; 1, which returns the lowest value; and 2, which returns the low value on row one and blanks on other rows.
  3. Anything between square brackets [] is an optional parameter. In this function, there are two optional parameters plus an optional qualifier.

An example of this function being used to rank the customers by their total sales would be:

How to use relational functions in visualisations

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

  • Whether you use the function in a dimension or measure will vary by each function. Visit the help pages for guidance.
  • The functions can be nested and combined with other types of functions.

Here is an example of using the Rank() function described above to rank customers by their total sales: