# Qlik Sense App Development

New Contributor II

## Top Customer vs Top Products

I am planning to achieve below 4th table for Top Customer vs Top Products.

Example:  have simple below 3 table charts results for sample Inline data added bottom.

All data in simple tables:

Expected result:

sample data:

custTable:
customer, product

'abc', 'p1'
'abc',  'p1'
'abc',  'p1'
'abc', 'p2'
'abc', 'p3'

'pqr',  'p1'
'pqr', 'p2'
'pqr',  'p2'
'pqr', 'p3'

'xyz', 'p5'
'EEE', 'p1'

];

Tags (1)
1 Solution

Accepted Solutions
MVP

## Re: Top Customer vs Top Products

Try these expression

1)

Count({<product = {"=Rank(Count(product)) < 3"}>} product)

2)

Count({<product = {"=Rank(Count(product)) < 3"}, customer = {"=Rank(Count({<product = {""=Rank(Count(product)) < 3""}>} product)) = 1"}>} product)

3)

Count({<product = {"=Rank(Count(product)) < 3"}, customer = {"=Rank(Count({<product = {""=Rank(Count(product)) < 3""}>} product)) = 2"}>} product)

7 Replies
Esteemed Contributor

## Re: Top Customer vs Top Products

Hi,

customer as a dimension

expressions like this:

1st: Count(   {<customer= {'abc'}  >}  product) ==> for TOP1 column

2nd: Count(   {<customer= {'pqr'}  >}  product) ==> for TOP2 column

MVP

## Re: Top Customer vs Top Products

Try these expression

1)

Count({<product = {"=Rank(Count(product)) < 3"}>} product)

2)

Count({<product = {"=Rank(Count(product)) < 3"}, customer = {"=Rank(Count({<product = {""=Rank(Count(product)) < 3""}>} product)) = 1"}>} product)

3)

Count({<product = {"=Rank(Count(product)) < 3"}, customer = {"=Rank(Count({<product = {""=Rank(Count(product)) < 3""}>} product)) = 2"}>} product)

New Contributor II

## Re: Top Customer vs Top Products

top 2 customer names should be dynamic

Esteemed Contributor

## Re: Top Customer vs Top Products

Ah ok ! so take Sunny's answer

New Contributor II

## Re: Top Customer vs Top Products

Hi Sunny,

working like charm, can you suggest me hoe to add names dynamically in the 3rd (abc)and 4th(pqr) headers?

MVP

## Re: Top Customer vs Top Products

Change this value

Count({<product = {"=Rank(Count(product)) < 3"}, customer = {"=Rank(Count({<product = {""=Rank(Count(product)) < 3""}>} product)) = 1"}>} product)

New Contributor II

Hi Sunny.