5 Replies Latest reply: Aug 20, 2017 6:56 PM by Sunny Talwar

# Top 3 countries and their sales in Text boxes

HI,

I have a table with countries and sales. No i have to display the top 3 countries in three different text boxes and their sales in the another three text boxes respectively.

Thanks

• ###### Re: Top 3 countries and their sales in Text boxes

Hi Vishnu,

Try like this,

For 1 st Rank in 1st text object:-

=Only(if(aggr(rank(sum(Sales)),Country)=1,Country))&'--'&sum({<Country={"=rank(Sum(Sales))=1"}>}Sales)

For 2 st Rank in 2st text object:-

=Only(if(aggr(rank(sum(Sales)),Country)=2,Country))&'--'&sum({<Country={"=rank(Sum(Sales))=2"}>}Sales)

.....Etc, Like rtry

Regards,

• ###### Re: Top 3 countries and their sales in Text boxes

May be this

=FirstSortedValue(DISTINCT Country, -Aggr(Sum(Sales), Country), 1) & Chr(10) &

Max(Aggr(Sum(Sales), Country), 1)

=FirstSortedValue(DISTINCT Country, -Aggr(Sum(Sales), Country), 2) & Chr(10) &

Max(Aggr(Sum(Sales), Country), 2)

=FirstSortedValue(DISTINCT Country, -Aggr(Sum(Sales), Country), 3) & Chr(10) &

Max(Aggr(Sum(Sales), Country), 3)

• ###### Re: Top 3 countries and their sales in Text boxes

Hi sunny stalwar1 ,

I have one doubt suppose this situation how we can solve?

Regards,

• ###### Re: Top 3 countries and their sales in Text boxes

I guess it depends on what the output needs to look like? Would it be A & C or A or C as the top 1?

• ###### Re: Top 3 countries and their sales in Text boxes

Hi, see the attached .qvw file. Hope it helps you.