Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
niranjana
Creator
Creator

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

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
Creator
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

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.