How You Will Use Aggregate Function in Qlik Sense Scripting?


Scott Campbell

Qlik Sense is a powerful data visualization and analysis tool that allows users to explore and gain insights from their data. One of the key features of Qlik Sense is its scripting language, which enables users to manipulate and transform data before it is loaded into the app. In this tutorial, we will explore how you can use aggregate functions in Qlik Sense scripting to perform calculations on your data.

What are Aggregate Functions?

Aggregate functions in Qlik Sense are used to perform calculations on multiple rows of data and return a single value. These functions are particularly useful when you want to summarize or aggregate data based on specific conditions.

There are several aggregate functions available in Qlik Sense, including:

  • SUM: Calculates the sum of a numeric field.
  • AVERAGE: Calculates the average of a numeric field.
  • MIN: Returns the smallest value from a numeric field.
  • MAX: Returns the largest value from a numeric field.
  • COUNT: Counts the number of rows in a dataset.

Using Aggregate Functions in Qlik Sense Scripting

To use aggregate functions in Qlik Sense scripting, you need to open the script editor by clicking on the “Edit Script” button in the Data Load Editor. Once inside the script editor, you can start writing your script using the following syntax:

   [Aggregate Function(Field3)] as [New Field]
   [Data Source];

In this example, we have three fields: Field1, Field2, and Field3. We want to calculate the sum of Field3 and create a new field called “New Field” to store the result. To achieve this, we use the SUM function as follows:

   SUM(Field3) as [New Field]
   [Data Source];

Similarly, you can use other aggregate functions like AVERAGE, MIN, MAX, or COUNT to perform different calculations based on your requirements.

Grouping Data with Aggregate Functions

In addition to performing calculations on individual fields, aggregate functions can also be used to group data and calculate aggregate values for each group. This is done using the GROUP BY clause in Qlik Sense scripting.

Let’s say you have a dataset containing sales information for different products in different regions. You can use an aggregate function like SUM along with the GROUP BY clause to calculate the total sales for each region.

   SUM(Sales) as TotalSales
   [Data Source]
Group By

In this example, we group the data by the “Region” field and calculate the total sales for each region using the SUM function.


Aggregate functions in Qlik Sense scripting are powerful tools that allow you to perform calculations on your data and derive meaningful insights. Whether you need to calculate sums, averages, counts, or perform other aggregations, Qlik Sense provides a range of functions to meet your needs. By leveraging these functions and understanding how to use them effectively in your scripts, you can unlock deeper insights from your data and make more informed decisions.

So go ahead and explore the world of aggregate functions in Qlik Sense scripting, and take your data analysis to the next level!

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy