Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Get sum of largest (by some value) 'x' rows via an expression

I have a table with cArticle, dSum and some other (irrelevant) fields. Let's say I created a QlikView table with theese two columns and a regular rank:Sample5.PNG

Now I want to get a sum(dSum) for largest (or smallest or whatever) 'x' rows, where x is a variable. How do I do that? I managed to display such sums in a table:

Sample4.png

I did this by having this as a dimension:

=IF(aggr(rank(sum(dSum)), cArticle) <= 3 ,'GroupA'

,IF(aggr(rank(sum(dSum)), cArticle) <= 6 and aggr(rank(sum(dSum),0,2), cArticle) > 3 ,'GroupB'

,IF(aggr(rank(sum(dSum)), cArticle) > 6,'GroupC'

)))

and sum(dSum) as an expression (I only used '3' and '6' numbers for convinience, those should be variables).

But I still can't calculate those sums in a single expression (to show in a text field for example), or apply different math operations based on different rank of cArticle

When I try to add a column to the last table, it takes rank of the group as a rank, not cArticle's rank as I want

So again, how do I get a sum of largest (or smallest or whatever) 'x' rows, where x is a variable?

1 Reply
Not applicable
Author