Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Which AGGR to use?

I recently had a query regarding how to use the AGGR function.  Although I managed to resolve, I still don't understand it.

Can anyone explain in very simple terms the difference between the following


Aggr(Sum ......)


&


Sum(Aggr(Sum .......)


I cannot seem to get my head around them.


When & Why do you use them?


Examples welcome to demonstrate.


Cheers



Phil

2 Replies
marcus_sommer

I'm not sure that I could explain it very well and therefore I suggest to look on the following postings:

AGGR...

Calculated Dimensions

In short: Aggr(Sum ......) will be used within calculated dimensions and Sum(Aggr(Sum .......) within expressions.


- Marcus

sunny_talwar

When you are using Aggr(Sum(....), the assumption is that there is only one value available after the inner Sum() is completed and that one value will be displayed. If for any reasons, there are more than one values, you will see - (null). Aggr(Sum(...) can be written like this Only(Aggr(Sum(....)) as they essentially mean the same exact thing.

Now Sum(Aggr(Sum(...)) is saying that if you have multiple values, then the expression should Sum those values and display it.

Here is an example for you to look at

Capture.PNG

I wanted to sum those rows where Dim2 began with D.... Since there are two such rows, the one without Sum() gave me null. Where as the one with Sum() gave me the right sum.

Does this make sense?