Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Bottom 5 values

Hi,

I have two charts that shows (or are supposed to show) top 5 and bottom 5. The top 5 is no problem, here's my expression in the dimension:

=aggr(if(rank(sum({$<AccountName={'3010'}>} Value))

  <=5) ,Product),Product)


And for the bottom 5, i thought that this would work:


=aggr(if(rank(-sum({$<AccountName={'3010'}>} Value))

  <=5) ,Product),Product)


My problem seem to be the "-" sign in front of sum. Aggr doesn't seem to like it.

Any ideas of how i can achive this? Dimension limit is not an option here since the dimension i want to rank by is the secound dimension after a cyclic group.

//A.

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

Change expressions as below

=sum({<Product = {"=Rank(-SUM({<Account = {'3010'}, Type = {'AC'}>}Value),4)<=5"}>}Value)/sum(TOTAL {<Product = {"=Rank(-SUM({<Account = {'3010'}, Type = {'AC'}>}Value),4)<=5"}>} Value)

or

=sum({<Product = {"=Rank(-SUM({<Account = {'3010'}, Type = {'AC'}>}Value),4)<=5"}>}Value)/sum(TOTAL Value)

View solution in original post

26 Replies
tresesco
MVP
MVP

It seems okay. Could you share sample qvw that demonstrates the issue?

er_mohit
Master II
Master II

sorry to edit up try this

=aggr(if(rank(-sum({$<AccountName={'3010'}>} Value),4)

  <=5 ,Product),Product)

Anonymous
Not applicable
Author

Tried that, doesn't work unfortunatly.

I'm thinking maybe the set analysis is the problem since it works if it isn't at set analysis that's beeing ranked and aggregated.

Not applicable
Author

try this?

=aggr(if(rank(sum({$<AccountName={'3010'}>} -Value))

  <=5) ,Product),Product)

Anonymous
Not applicable
Author

Here's a test application

MK_QSL
MVP
MVP

Like this?

Calculated Dimension

=IF(Aggr(Rank(-SUM({<Account = {'3010'},Type = {'AC'}>}Value),4),Product)<=5,Product)

Expression

Total Value

SUM({<Account = {'3010'},Type = {'AC'}>}Value)

Rank

Rank(SUM({<Account = {'3010'},Type = {'AC'}>}Value),4)

nizamsha
Specialist II
Specialist II

Top 5 u can use this

if(rank(sum({$<AccountName={'3010'}>} Value))<=5,sum({$<AccountName={'3010'}>} Value)

bottom 5 u can use this

if(rank( rank(sum({$<AccountName={'3010'}>} Value)))<=5,sum({$<AccountName={'3010'}>} Value))


tresesco
MVP
MVP

Use one more Aggr() like:

=aggr(if(Aggr(rank(-sum({$<Account={'3010'}, Type={'AC'}>} Value),4)<=5, Product),Product), Product)

arjunkrishnan
Partner - Creator II
Partner - Creator II

TRY THIS ONE

=aggr(if(rank(sum(Revenue))<=5 or rank(-sum(Revenue))<=5,Customer),Customer)