When building visualisations in Qlik Sense, you have to work with dimensions and measures. Dimensions are data that group metrics such as date, category, product, year, customer name, etc. Measures are the data being grouped, such as the number of orders, the total spend, the number of clients, etc. Both types of metrics likely require calculations beyond what has been done during the data model build. Chart scripting is using functions to perform these calculations.

Most functions useable in the data load editor can also be used when scripting in visualisations. Please re-visit the various functions pages using the menu on the left for in-chart use examples. However, there are some functions that are only useable in visualisations. We will cover these functions in this article. Note that there are many working Qlik Sense functions. Functions are subject to being updated or phased out. For an up-to-date list of functions, please see the Qlik Sense help pages here.

Aggregation Functions

Aggregation functions are functions that group multi-row data into a single row based on some grouping.

The functions are calculated by looping through the table rows and working out the result for each given group. All aggregation functions apart from one can be used in the script. The function specific to chart scripting is as follows:

AggrThe Aggr() function ‘aggregated’ values over a dimension. For example, the minimum date of purchase per customer. The result of the function can be used as is in a dimension field, or it can be enclosed in another aggregation function to create a nested set of aggregation calculations.

See more on the Aggr() function here.

Colour Functions

Colour functions are for setting and evaluating a specific colour for a measure or a dimension. They allow you to use a specific code that Qlik will convert into a colour, but also, Qlik has a predefined set of colours that you can refer to within a visualisation. Here are some examples of colour functions:

RgbThe Rbg() function allows you to specify the red, green and blue colour values and returns an integer corresponding to those. This can then be used to colour a visualisation.
BlackThe Black() function returns an integer equivalent to Rgb values 0,0,0. It can be used to colour visualisations.

See more on colour functions here.

Field Functions

Field functions return information about field selections in the app. Here are some examples of field functions for chart scripting:

GetCurrentSelectionsThe GetCurrentSelections() function returns information about filters currently applied in the app.
GetFieldSelectionsThe GetFieldSelections() function returns information about filters applied in a specific field.
GetPossibleCountThe GetPossibleCount() function returns the number of possible selections in a given field.

See more on field functions here.

Inter-record Functions

Some inter-record functions can only be used in the script while others can only be used in visualisations. In visualisations, inter-record functions are used when a value from a different part of the visualisation is needed for the calculation, e.g. the row above. Here are some examples of inter-record functions for visualisations:

AboveThe Above() function returns the evaluated value from the row above the current one in a table or a visualisation. The column doesn’t have to be identical; an offset can be used to look for a value in a different column.
TopThe Top() function returns the evaluated value from the top row of a current table or visualisation. The column doesn’t have to be identical; an offset can be used to look for a value in a different column.

See more on inter-record functions here.

Relational Functions

Relational functions are for returning information on where a calculated value sits relative to all other values. Here are some examples of relational functions for visualisations:

RankThe Rank() function ranks a value relative to other values in a given column and returns the order. E.g. rank total customers’ orders from most to least.
STL_TrendThe STL_Trend() function will return the trend of time series data, disregarding the seasonal component.

See more on relational functions here.