Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
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