Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Top 3 Company Over 2 Years

Hello Friends,

I have following table,

CompanySalesYear
A2052006
A3012005
A562004
B2572006
B6542005
B1472004
C2562006
C652005
C592004
D5982006
D2542005
D102004

and I have to find top 2 company over past 2 years, I want an output table as

ComapanySales
B911
D852
A506

please if anyone has any idea,help me out

1 Solution

Accepted Solutions
Not applicable
Author

=sum({$<Year={vCurrentYear},Year={vLastYear}>}Sales)

Where the variables are for the two years that you want to sum over

View solution in original post

14 Replies
Not applicable
Author

create a table with company as a dimension, and then use an expression that outputs the sum of sales over the 2 year period

Then choose to display only the top three results

Not applicable
Author

Hi

try this

=FirstSortedValue(Company,

(-aggr(sum(Sales), Company))

)

bets regards

Chris

Not applicable
Author

How would I Sum of sales over 2 Year period? Thats exactly I want,please share the expression

tresesco
MVP
MVP

=Sum({<Year={">$(=Max(Year)-2) <=$(=Max(Year))"}>}Sales)

Not applicable
Author

=sum({$<Year={vCurrentYear},Year={vLastYear}>}Sales)

Where the variables are for the two years that you want to sum over

its_anandrjs

Take the straight table and

Dimension:- Company

Expression:- if( Rank(Sum({<Year = {'>=$(=Max(Year-1)) <=$(=Max(Year))'} >} Sales)) <= 3, Sum({<Year = {'>=$(=Max(Year-1)) <=$(=Max(Year))'} >} Sales))

This will give as out put that you want see snap

Max3Company.png

If you want to get only for last 2 years data then use

Exper:-  Sum({<Year = {'>=$(=Max(Year-1)) <=$(=Max(Year))'} >} Sales))

Not applicable
Author

Like this

Not applicable
Author

Sorry, this one shows the top 3 values

Not applicable
Author

Thank you Robert