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

14 Replies
eduardo_sommer
Partner - Specialist
Partner - Specialist

Hi

I created a qvw with a straight table, with Company as the Dimension and the expression

        =sum({$<Year={'$(=Max(Year))','$(=Max(Year)-1)'}>} Sales)

On the Dimension Limits, I set to show only te 2 largest values, with no Other.

See the attached qvw.

Eduardo

its_anandrjs

Hi Bhawna,

Did you check the result of the expression =sum({$<Year={vCurrentYear},Year={vLastYear}>}Sales)

you get only sum of last 2 years but not B,D,A as you discussed in the post for top3 for last 2 years did you try with the this expression

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

Which will give for last 2 years sales and for top 3 customers with ranking use.

Over all Robert expression is correct but not ranking the expression


Regards

Not applicable
Author

Thank you Friends for helping me by giving your ideas.. thank you so much all

ravindraa
Creator
Creator

Hi Robert Daitzman,

  I have also same requierment i am using your logic but i have used variables instead of direct year's like

vcurrentyear=year(this is my field)

vpreviousyear = max(year)-1

i am trying to write set analysis like below but i am not getting any value it is showing emty table if you know any suggession please give to me.

i have used below  two expression :

 

=sum({$<Year2={vcurrentyear},Year2={vpreviousyear}>}Sales2) .

 

=sum({<Year2={"$(=vCurrentYear)"},Year2={"$(=vpreviousyear)"}>}sales2)

Not applicable
Author

Ravindraa,

Which of those two expressions uses the correct field names?  Those two have different capitalizations which will be pointing towards differing fields