Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

surynnchin
New Contributor III

Count distinct product

Untitled.jpg

Hi

I want to count distinct product for Region A and Region B but only if the product exists in all the stores in the region.

Count for Region A= 2(C&E)

Count for Region B= 3(B&C&E)

Any idea how to achieve this?

Thanks in advance.

1 Solution

Accepted Solutions

Re: Count distinct product

Try:

sum(if(aggr(nodistinct count(distinct total <Region> Store),Region,Product)=aggr(count(distinct Store),Region,Product),1,0))-=[Regional Count]- count({<Product={'=count(distinct Store)=count(total distinct Store)'}>}distinct Product)


talk is cheap, supply exceeds demand
7 Replies

Re: Count distinct product

sum(if(aggr(count(distinct total <Region> Store),Region,Product)=aggr(count(distinct Store),Region,Product),1,0))

see attached example.

edit: I don't know what you're looking at, but it can't be the example I posted. That shows 2 for Region A and 3 for Region B.

comm87463.png


talk is cheap, supply exceeds demand
surynnchin
New Contributor III

Re: Count distinct product

Hi Gysbert

Thanks for reply but count for Region A =2 not 11 and Region B=3 not 12 because i want to count only common product which exists in all the 5 stores in Region A and 3 Stores in Region B.

Count for Region A= 2 (all 5 stores in region A have Product C & Product E )

Count for Region B= 3 (all 3 stores in region B have Product B & Product C & Product E)

surynnchin
New Contributor III

Re: Count distinct product

Hi Gysbert

Figure it out, instead of

sum(if(aggr(count(distinct total <Region> Store),Region,Product)=aggr(count(distinct Store),Region,Product),1,0))

i should put

sum(if(aggr(NODISTINCT count(distinct total <Region> Store),Region,Product)=aggr(count(distinct Store),Region,Product),1,0))

Thanks for solved my problem to get the regional count.

Now I can't get my global count correctly, can you help me on this as well?

All the 8 stores have common product C and E, then Global Count=2 (C&E)

Since product C & E are count in global level, so

Product Count for region A=2-2=0

Product Count for region B=3-2=1 (B)

I wish to get the result as below:

Untitled.jpg

surynnchin
New Contributor III

Re: Count distinct product

anyone got idea how to solve this problem?

Re: Count distinct product

Try:

sum(if(aggr(nodistinct count(distinct total <Region> Store),Region,Product)=aggr(count(distinct Store),Region,Product),1,0))-=[Regional Count]- count({<Product={'=count(distinct Store)=count(total distinct Store)'}>}distinct Product)


talk is cheap, supply exceeds demand
surynnchin
New Contributor III

Re: Count distinct product

Thanks Gysbert

Thank you so much

surynnchin
New Contributor III

Re: Count distinct product

1

Community Browser