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

Announcements
Q&A with Qlik - Qlik Cloud Migration: Questions about migrating to Qlik Cloud? Catch the latest replay!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

comparing customers and ranking

Hi,

I was trying to  compare customers in specific year and show  the best 5 customers in terms of sales.

here is my script:

=if(aggr(rank(Sum({<Year = {'$(=Max(Year))'}>}Sales)),Year,Customer)=5, Customer)

it seems that scripts returns " the 5th" in rank instead of  " the 5 best customers". Any idea ?

thanks

Labels (1)
1 Solution

Accepted Solutions
its_anandrjs
Champion III
Champion III

Try like below script

=if(aggr(rank(Sum({<Year = {'$(=Max(Year))'}>}Sales)),Year,Customer)>5, Customer)


Or


=if(aggr(rank(Sum({<Year = {'$(=Max(Year))'}>}Sales)),Year,Customer)<5, Customer)


Or


=if(aggr(rank(Sum({<Year = {'$(=Max(Year))'}>}Sales)),Year,Customer)<=5, Customer)

View solution in original post

6 Replies
its_anandrjs
Champion III
Champion III

Try like below script

=if(aggr(rank(Sum({<Year = {'$(=Max(Year))'}>}Sales)),Year,Customer)>5, Customer)


Or


=if(aggr(rank(Sum({<Year = {'$(=Max(Year))'}>}Sales)),Year,Customer)<5, Customer)


Or


=if(aggr(rank(Sum({<Year = {'$(=Max(Year))'}>}Sales)),Year,Customer)<=5, Customer)

MK_QSL
MVP
MVP

IF(Aggr(Rank(SUM({<Year = {'$(=Max(Year))'}>}Sales),4),Customer)<=5, Customer)

ashfaq_haseeb
Champion III
Champion III

Hi try

below code.

=if(aggr(rank(Sum({<Year = {'$(=Max(Year))'}>}Sales)),Year,Customer)<=5, Customer)

Regards

ASHFAQ

anbu1984
Master III
Master III

Replace = by <=

=if(aggr(rank(Sum({<Year = {'$(=Max(Year))'}>}Sales)),Year,Customer)<=5, Customer)

Not applicable
Author

Thanks  a lot

Is there a way to sort out ?  Best customer highest in the list ?

MK_QSL
MVP
MVP

Create a new thread !