Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
cindy_user
Contributor III
Contributor III

How to understand and use aggr functions?(new user)

Hi all,

I have been looking at the documentation related to the aggr function recently and tried to use it on qs.But I find it difficult to understand it and I have a few questions about it.

1.Does the dimension of this virtual table (aggr) need to be consistent with the dimension of the chart?My understanding is that the granularity of the dimensions in aggr needs to be smaller than that of the chart. Because the outside aggregation function needs to aggregate the virtual table twice.I don't know if my understanding is wrong.

But I will see this situation in the answers of others: the outside dimension is not in the dimension of the virtual table, I cannot understand how to perform secondary aggregation like this?

2.Where should the set analysis in the aggr function be placed?

For example, to filter the year, why do I get the wrong answer when I specify it in aggr? Must be specified outside to get the correct answer?

In the screenshot below, I selected the data of 2012, 8900 is the correct result. If I don't specify 2013 outside, I will get 8000 wrong results.

1.PNGCapture.PNG

Hope someone can answer my question. I will be very grateful.

 

Labels (1)
  • SaaS

2 Replies
marcus_sommer

To 1. and 2. it depends on the data, datamodel and the requirements to display certain results. This means the dimensions within the aggr() may be identically with those from the object (probably the most common case) but it mustn't mandatory. Also you may need (different) set analysis in each aggregation part - inside and outside aggregations - there is no general rule for it.

The official recommendation is to avoid aggr() and multiple/complex conditions within the expressions and using instead simple expressions like sum(field) or count(field). Only if it's really not possible - means using different objects/views and appropriate selections and of course also some adjusting within the script/datamodel - you should consider more complex calculations within the UI.  

- Marcus

vhayward
Partner - Contributor III
Partner - Contributor III

Hi,

Aggregate functions, but also other calculations within any Qlik Sense viz. object are performance consuming solutions, especially with large sets of data. The object calculation time of these objects are high, which impacts the user experience. You can test it with the Qlik Sense Document Analyzer from Rob Wunderlich at Tools | Qlikview Cookbook

I would try to solve aggregates within the data model itself. It's easier to maintain as well.
Maybe not the answer you thought of, but from my experiences these 'could-be-very-expensive' calculations should not be done in front-end.

Best regards,
Vincent Hayward