Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Ranking aggregate values in text object

Hi,

I have an aggregate function that gives the following results:

CustomerProductSale
XA$10
XB$20
YC$500
YD$60

My aggregate function is as follows:

aggr(sum(Sale),Customer,Product)

However, I want to put the customer-product combination into a text object, along with where the combination ranks in terms of sale. Example:

If my filter is customer Y, Product C, I want to see the Rank as follows:

Customer-Product     Rank

Y-C                              1

If my filter is Customer Y, Product D, I want to see the Rank as follows:

Customer-Product     Rank

Y-D                              2

Meaning I just want to display the rank in a text object. How can I achieve this? Thanks.

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

Try this expression:

=If(GetSelectedCount(Product) = 1 and GetSelectedCount(Customer) = 1,

Aggr(If(Sum(Sale)> 0,Rank(TOTAL sum({<Product =, Customer =>}Sale))), Product, Customer))

View solution in original post

4 Replies
Kushal_Chawda
MVP
MVP

Please see the attached

sunny_talwar
MVP
MVP

Try this expression:

=If(GetSelectedCount(Product) = 1 and GetSelectedCount(Customer) = 1,

Aggr(If(Sum(Sale)> 0,Rank(TOTAL sum({<Product =, Customer =>}Sale))), Product, Customer))

Not applicable
Author

Hi,

I realised you did the ranking via the Script. Is it possible to do it entire in the set analysis instead, rather than a script? Thanks.

Not applicable
Author

This works well. Apparently I needed to add in the total keyword in my rank function.