Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Sean_BI
Creator
Creator

Top 3 products using AGGR

Dear Team -

I need to display top 3 products in a straight table based on attached data.

when i select a specific product from the list box the straight table should display top3.

when i select two product from the list box, the straight table should display top3 of each product it total 6 rows i should get i.e first top 3 of product 1 and next top 3 of product 2.

Appreciate your help. I am struggling using AGGR and rank.

Rgds,

Sen.

Labels (2)
12 Replies
Kushal_Chawda

share sample data to work with?

Sean_BI
Creator
Creator
Author

Thank you for your response kush.

I've attached the sample data.

Rgds,

sean.

Kushal_Chawda

try below

 

=sum(total <Product>{<Period,Year,Month,Period={">=$(=yearstart(max(Period)))<=$(=max(Period))"}>}
aggr(if(rank( sum({<Period,Year,Month,Period={">=$(=yearstart(max(Period)))<=$(=max(Period))"}>}[Price($)]),0,4)<=2,
sum({<Period,Year,Month,Period={">=$(=yearstart(max(Period)))<=$(=max(Period))"}>}[Price($)])),Product,[Customer Code]))