Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
alanwong1178
Contributor III
Contributor III

Top N in Pivot table multiple dimension

Hi All,

I would like to have a pivot table with two dimension: 1) Client 2)Region which shows the top 3  region for each client based on the profit as requirement below: 

 

alanwong1178_4-1635324092031.png

 

 

I tried to write something like: 

aggr(if(rank(SUM(Profit))<=3,Region),Region)

It does not work as it is based on the ranking of the total profit of region rather than the ranking of profit of region for each individual client. This gives me some weird result

alanwong1178_1-1635323879827.png

Weird result:

alanwong1178_2-1635323985012.png

 

Ideal Result:

alanwong1178_3-1635324071925.png

 

 

Labels (3)
3 Replies
abhijitnalekar
Specialist II
Specialist II

Hi @alanwong1178 ,

 

Please update your formula like below.

=if(aggr(rank(Sum(Profit),Client),Client,Region ) <=3, Region)

 

Regards,
Abhijit
keep Qliking...
Help users find answers! Don't forget to mark a solution that worked for you!
NitinK7
Specialist
Specialist

try to add calculated dimension for region

Dimension:

Client 

=Aggr(If(Aggr(Rank(Sum(profit))<=3,Client,Region), Region), Client,Region )

Measure

Sum(Sales)

Sum(profit)

 

NitinK7_0-1635327256472.png

 

abhijitnalekar
Specialist II
Specialist II

Hi @alanwong1178 ,

 

Please update expression as below

=Aggr(If(Aggr(Rank(Sum(Profit),Client,Region)<=3,Client,Region), Region), Client,Region )

abhijitnalekar_0-1635327636135.png

 

Regards,
Abhijit
keep Qliking...
Help users find answers! Don't forget to mark a solution that worked for you!