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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
niranjana
Creator II
Creator II

Display top 5 countries

Hi

I have a requirement where i have to display top 5 countries with maximum sales in qliksense text box. Not sales, but top 5 countries with sales. Is it possible using aggregate function in a single line?

Thanks in advance

3 Replies
MayilVahanan
MVP
MVP

Hi @niranjana 

Try like below

=Concat(Aggr(If(Rank(Sum(Sales))<= 5, Country&'('&Sum(Sales)&')'), Country), ',', Aggr(Rank(Sum(Sales)), Country))

It will display Country & Sales with highest rank to lowest rank

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
niranjana
Creator II
Creator II
Author

Thanks a lot...it is working ..what if i want to show from 2nd like 2nd to 5th rank..excluding the first topmost country?

MayilVahanan
MVP
MVP

Hi @niranjana 

In that case, change the if condition

=Concat(Aggr(If(Rank(Sum(Sales))>1 and Rank(Sum(Sales)) <=5, Country&'('&Sum(Sales)&')'), Country), ',', Aggr(Rank(Sum(Sales)), Country))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.