Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
WEBINAR April 23, 2025: Iceberg Ahead: The Future of Open Lakehouses - REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

aggr( help with returning a dimension instead of expression

=max(aggr(count([t1Sales_Name and Cluster code]),[t1Sales_Name and Cluster code]))

This is my code (which doesn't work...

Table looks like so

[t1Sales_Name and Cluster code]              /      Sales

Test                                                         /      1000

Test1                                                       /      2000

I would like my aggr function to work out what [t1Sales_Name and Cluster code] has the highest sales value.

Expected output would be

Test1

Let me know if I've not been clear enough,

james.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

If your sales field is named Sales try this:

=FirstSortedValue([t1Sales_Name and Cluster code], -aggr(sum(Sales),[t1Sales_Name and Cluster code]))


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

If your sales field is named Sales try this:

=FirstSortedValue([t1Sales_Name and Cluster code], -aggr(sum(Sales),[t1Sales_Name and Cluster code]))


talk is cheap, supply exceeds demand
Not applicable
Author

Hey I know this is very greedy, but I have another problem. Could you perhaps write the aggr for me?

Imagine this:

[t1Sales_Name and Cluster code]    --     Count([t1Sales_Name and Cluster code])

Test                                             --          2

Test 1                                             --   1

would it be the same as your given example above?