Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

to pick TOP-20 values

Hi,

I'm using the following expression to pick TOP-20 values:

Sum({$<Brand={"=rank(sum({$<Brand=>} Quantity ))<=20"}>} Quantity)

Please, see the file attached.

It works fine except for some cases. For instance, if Brand No20 and Brand No21 have the same sum(Quantity), then QlikView picks only first 19 brands. My task is to select 21 brands in such cases. It means that if it's not possible to select exactly 20 brands, then the programm should select 21 but not 19. How is it possible?

Thank you in advance,

Larisa

1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

hi

just change your expression to

Sum({$<Brand={"=rank(sum({$<Brand=>} Quantity ),1,1)<=20"}>} Quantity)

which set the rank format to return the lower value for to identical values

so instead of returning 20-21 in your example it'll return 20 to both entities

View solution in original post

2 Replies
lironbaram
Partner - Master III
Partner - Master III

hi

just change your expression to

Sum({$<Brand={"=rank(sum({$<Brand=>} Quantity ),1,1)<=20"}>} Quantity)

which set the rank format to return the lower value for to identical values

so instead of returning 20-21 in your example it'll return 20 to both entities

Anonymous
Not applicable
Author

Thanks a lot!