Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Akina0929
Creator
Creator

How to show top 3 and bottom 3 sales in textbox?

Hi community,

           I have country as dimension and sales as expression. I want to show top 3 and bottom 3 sales in Textbox.

Please help me .

Regards

Anji

1 Solution

Accepted Solutions
micheledenardi
Specialist II
Specialist II

2017-12-01 09_24_13-QlikView x64 Personal Edition - [C__Users_Michele.Denardi_Desktop_Test.qvw_].png

='Highest Sales' &CHR(13)&CHR(13)&

FirstSortedValue(Country, -aggr(sum(Sales),Country)) &': '& sum({<Country={'$(=FirstSortedValue(Country, -aggr(sum(Sales),Country)))'}>}Sales) & chr(13) &

FirstSortedValue(Country, -aggr(sum(Sales),Country),2)&': '& sum({<Country={'$(=FirstSortedValue(Country, -aggr(sum(Sales),Country),2))'}>}Sales) & chr(13) &

FirstSortedValue(Country, -aggr(sum(Sales),Country),3)&': '& sum({<Country={'$(=FirstSortedValue(Country, -aggr(sum(Sales),Country),3))'}>}Sales)

='Lowest Sales' &CHR(13)&CHR(13)&

FirstSortedValue(Country, +aggr(sum(Sales),Country)) &': '& sum({<Country={'$(=FirstSortedValue(Country, +aggr(sum(Sales),Country)))'}>}Sales) & chr(13) &

FirstSortedValue(Country, +aggr(sum(Sales),Country),2)&': '& sum({<Country={'$(=FirstSortedValue(Country, +aggr(sum(Sales),Country),2))'}>}Sales) & chr(13) &

FirstSortedValue(Country, +aggr(sum(Sales),Country),3)&': '& sum({<Country={'$(=FirstSortedValue(Country, +aggr(sum(Sales),Country),3))'}>}Sales)

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

6 Replies
swuehl
MVP
MVP

Maybe something like

=Sum({<Country = {"=Rank(Sum(Sales))=1"}>}Sales) // top sales

=Concat({<Country = {"=Rank(Sum(Sales))=1"}>} DISTINCT Country,', ') // top country


=Sum({<Country = {"=Rank(-Sum(Sales))=1"}>}Sales) // bottom sales

=Concat({<Country = {"=Rank(-Sum(Sales))=1"}>} DISTINCT Country,', ') // bottom country


adapt 1 to 2,3 for second, third ...


edit: used Concat() to show ties.

micheledenardi
Specialist II
Specialist II

2017-12-01 09_24_13-QlikView x64 Personal Edition - [C__Users_Michele.Denardi_Desktop_Test.qvw_].png

='Highest Sales' &CHR(13)&CHR(13)&

FirstSortedValue(Country, -aggr(sum(Sales),Country)) &': '& sum({<Country={'$(=FirstSortedValue(Country, -aggr(sum(Sales),Country)))'}>}Sales) & chr(13) &

FirstSortedValue(Country, -aggr(sum(Sales),Country),2)&': '& sum({<Country={'$(=FirstSortedValue(Country, -aggr(sum(Sales),Country),2))'}>}Sales) & chr(13) &

FirstSortedValue(Country, -aggr(sum(Sales),Country),3)&': '& sum({<Country={'$(=FirstSortedValue(Country, -aggr(sum(Sales),Country),3))'}>}Sales)

='Lowest Sales' &CHR(13)&CHR(13)&

FirstSortedValue(Country, +aggr(sum(Sales),Country)) &': '& sum({<Country={'$(=FirstSortedValue(Country, +aggr(sum(Sales),Country)))'}>}Sales) & chr(13) &

FirstSortedValue(Country, +aggr(sum(Sales),Country),2)&': '& sum({<Country={'$(=FirstSortedValue(Country, +aggr(sum(Sales),Country),2))'}>}Sales) & chr(13) &

FirstSortedValue(Country, +aggr(sum(Sales),Country),3)&': '& sum({<Country={'$(=FirstSortedValue(Country, +aggr(sum(Sales),Country),3))'}>}Sales)

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
senpradip007
Specialist III
Specialist III

Use FirstSortedValue to retrieve top / bottom country based on Sales.

Try like:

Top:

sum({<Country={'$(=FirstSortedValue(Country, -aggr(sum(Sales),Country)))'}>}Sales)


Bottom:

sum({<Country={'$(=FirstSortedValue(Country, aggr(sum(Sales),Country)))'}>}Sales)

Akina0929
Creator
Creator
Author

Hi Michele,

    Thank you very much for your Replay.

Regards

Anji

micheledenardi
Specialist II
Specialist II

You're welcome!

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
varma8998
Contributor III
Contributor III

Hi ,

if I am calculating direct sum (sales) I am getting value

but the problem is we have to take few filters from each column to calculate the sales

example

columns are Curreny, Scenario, Code, Year, Sales_Amount we have columns like this

Column Values Curreny(USD), Scenario(forecast), Code(1apsjc), Sales_Amount