Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
hic
Former Employee
Former Employee

When a calculation is made in a QlikView session, it always involves an aggregation over the relevant data records. But which records are relevant? What is the scope of the aggregation?

This seems like a simple question, but there are in fact quite a few things that could be said about it.

 

Normally, there are two different restrictions that together determine which records are relevant: The Selection, and – if the formula is found in a chart – the Dimensional value. The aggregation scope is what remains after both these restrictions have been taken into consideration.

 

But not always…

 

There are ways to define your own aggregation scope: This is needed in advanced calculations where you want the aggregation to disregard one of the two restrictions. A very common case is when you want to calculate a ratio between a chosen number and the corresponding total number, i.e. a relative share of something.

 

Aggregation expression 2.png

 

In other words: If you use the total qualifier inside your aggregation function, you have redefined the aggregation scope. The denominator will disregard the dimensional value and calculate the sum of all possible values. So, the above formula will sum up to 100% in the chart.

 

Dimensional scope.png

 

However, there is a second way to calculate percentages. Instead, you may want to disregard the the selection in order to make a comparison with all data before any selection. Then you should not use the total qualifier; you should instead use Set analysis:

 

Aggregation expression 3.png

 

Using Set analysis, you will redefine the Selection scope. The set definition {1} denotes the set of all records in the document; hence the calculated percentages will be the ratio between the current selection and all data in the document, split up for the different dimensional values.

 

Selection scope.png

 

In other words: by using the total qualifier and set analysis inside an aggregation function, you can re-define the aggregation scope.

 

  • To disregard the dimensional grouping – Use the Total qualifier
  • To disregard the selection – Use Set Analysis

 

The above cases are just the basic examples. The total qualifier can be qualified further to define a subset based on any combination of existing dimensions, and the Set analysis can be extended to specify not just “Current selection” and “All data”, but any possible selection.

 

And, of course the total qualifier can be combined with Set analysis.

 

Aggregation expression.png

 

A final comment: If an aggregation is made in a place where there is no dimension (a gauge, text box, show condition, etc.), only the restriction by selection is made. But if it is made inside a chart or an Aggr() function, both restrictions are made. So in these places it could be relevant to use the total qualifier.

 

HIC

 

Further reading related to this topic:

What does the TOTAL qualifier do?

Totals in Charts

A Primer on Set Analysis

13 Comments
Not applicable

Hey guys, 

I am given a task to calculate the frequency of calls across a territory. If the rep called a physician regarding the sale of the product 5 times, then frequency is 5 and HCP count is 1....I generated frequencies from 1 to 124 in my pivot table using a calculated dimension which is working fine. But my concern is :

My manager wants frequencies till 19 in order from 1..2..3..4...5..6.....19...

And from the frequency 21-124 as 20+.

I would be grateful if someone helps me with this.....Eager for the reply....

0 Likes
13,675 Views
Anonymous
Not applicable

HIC, Thanks !!

Always a nice time reading your blogs there are people who make simple things Complex

you are the one who has art of expressing complex things in simple way.

you are the one person I want to adore folow mentor and be like,

even I started copying your signature style.

Good Wishes !!

Anant

0 Likes
13,675 Views
Anonymous
Not applicable

Simple and good read.. I finally understood the difference between total and {1}

0 Likes
13,545 Views