Math functions are used for mathematical applications.

This article will cover the basic principles of working with these functions in the data load editor and visualisations, including:

  • The general function syntax
  • Working with math functions in the data load editor
  • Working with math functions in visualisations

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

The math function syntax

Usually, the general function syntax varies depending on the function. However, math functions do not require any input parameters, therefore, the syntax is identical for them all. In this section, we will use an example function and decipher how to use it. This knowledge can then be applied to all math functions.

Example 1: True

The True() function returns a logical value of true which is equivalent to -1. Note that the function doesn’t take any parameters but parenthesis are still required to call the function.

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, there are no elements to enter.
  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 the same as the syntax:

The resulting field would contain -1.

How to use math functions in the data load editor

Here are some important points on using the functions in the data load editor:

  • All of the functions can be used throughout the whole load script, not just within a LOAD or SELECT statement
  • The functions can be nested and combined with other types of functions

Here is an example of the True() and False() functions being used:

CUSTOMERS:
LOAD
    "Customer ID",
    "Customer Name",
    "Customer Phone",
    "Customer Address",
    If(IsNull("Customer Name") or IsNull("Customer Phone") or IsNull("Customer Address"), True(), False()) as "Customer Has Missing PI"
    
FROM [customers.qvd] (qvd);

The newly created field “Customer Has Missing PI” in the resulting Qlik table has -1 when any of the customer’s personal information is missing. For customers where all fields are not NULL, the new field contains a 0.

How to use math functions in visualisations

At the time of writing, all math functions can be used in visualisations in the same way that they are used in the data load editor.

  • The functions can be nested and combined with other types of functions.
  • The functions can be used in dimensions or measures depending on your requirements.

Here is an example of using the functions in a data table visualisation. We used the math True() and False() functions to identify those customers that are a limited company. The formula used in the visualisation is:

If(WildMatch([Customer Name],'* Ltd*'),True(),False())