Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum of Top n values in a text field

Hi all,

I'm trying to calculate the sum of the 5 largest values of one dimension. I tried set analysis and Aggr fuction combined with the Rank() function but did not succeed yet.

Attached a simple example of my problem:

  • 20 entries (line items) of "sales records".
  • 10 different customers
  • The TOP5 customers have a total of 51,446 sales.

This sum (51,446) is what I would like to calculate in a formula to replace the static blue coloured text.

Thank you!

topsums.PNG

1 Solution

Accepted Solutions
Not applicable
Author

I'm still not sure why I was getting a different result in QV vs QS but the expression you need is this:

Copy directly into your app

SUM({<Customer={"=sum(Sales)>=$(=max(aggr(sum(Sales),Customer),5))"}>}Sales)

View solution in original post

3 Replies
Not applicable
Author

Hi David,

There seems something a bit odd going on here, I'm getting a different result from the same expression in QlikView vs QlikSense. 

The expression below works fine in QlikView (chart or text box) but in QlikSense it just seems to pick one value for a customer. Qlik monitor these threads so hopefully someone there can explain why?

sum({<Customer = {"=rank(sum(Sales))<=5"}>}  Sales) 

Hope this helped, thanks.

ramoncova06
Specialist III
Specialist III

check this thread Customers Having Top 4 Values

Not applicable
Author

I'm still not sure why I was getting a different result in QV vs QS but the expression you need is this:

Copy directly into your app

SUM({<Customer={"=sum(Sales)>=$(=max(aggr(sum(Sales),Customer),5))"}>}Sales)