I’m very pleased to announce that one of our very favorite functions has been finally upgraded with a nice and longtime requested functionality. Aggr() virtual table is now sortable!
Note: For those of you not familiar with what Aggr() is and what can do for you, please review the following materials:
Despite the fact that we have been able to do some crazy stuff with Aggr(), every time we wanted to explore the possibilities of inter-record or range functions we faced a wall, Aggr() array of values couldn’t be sorted by any means. You couldn’t control how the data was ‘stored’ in the aggr() virtual table (load order by default) making it hardly usable for a variety of cases such as cumulative calculations, inter-record and range calculations, etc.
From now on, we count in with a brand new Aggr() chart function that allows us to sort the resulting array (both in Qlik Sense 2.2 and QlikView 12*). The magic happens in the new StructuredParameter.
An Aggr() array can contain virtually anything so you have to specify what data type will be sorted within the array of data (numeric, text, frequency or Load_Order) and the sort criteria, basically ASC or DESC. I strongly recommend you to check the Aggr() help page and get familiar with the new syntax.
Real life example
Please read this blog post to discover a real usage scenario.
(...) I needed to capture the percentage and number of the gains and losses in a KPI object(...) In order for the Aggr() function to work as I expected, I needed to make sure the MonthYear field was sorted properly in ascending order so I handled this in my script. Note that if the MonthYear field was not in ascending order, the Above() function may not always return the previous month thus returning the wrong results.
Now, to solve Jennell's dilemma we could simply use Aggr() avoiding any extra steps such as sorting the data in the script and making our calculation fully dynamic.
Olá, Unfortunately I don't know what the plans are for Aggr. This update came out of the blue for me but if I hear/read anything that can be shared I will update the post.
Use an expression as sort parameter would be a great feature to build ABC Analysis.
For example, create a KPIs objects that show me number of Customer in A, B or C Tier using sum(Sales) descending as Sort Order and Customer ID as dimension.
Wow... Close but no cigar is my first impression from reading this. So, someone has gone through the trouble of revising the Aggr statement - but yet, did not add what was most sorely missing? Just search through the Ideas page and you'll see an idea raised a good six years ago by yours truly quoting a genuine, recurring use case for dynamic sorting which is the humble Pareto calculation. I'm happy to stand corrected, but I can't see any way of benefitting from this configurablestatic sort for solving that use case. in fact, I struggle to see many use cases at all for this feature unfortunately. Was this released in a Beta version? Did you capture any community feedback on whether this feature enhancement would meet any real world needs? If there is a second development iteration of this feature, please do not hesitate to reach out - I'd happily participate in improving upon this feature. For those of you in the community who wish to see dynamic sorting of the Aggr statement in the future, please follow this link and cast your vote behind the original idea: