Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
TheresaB_4
Contributor III
Contributor III

Count of different products per customer account

Hi Everyone, 

I need some help with this one. I have tried a few other solutions but can they do not work. I know it might be simple but I can not seem to get it right.

A little background.

You have customer_accounts and some have productA or ProductB ot both products.
I want to show a pivot with distinct customer nr, in 3 different categories. Count of product A, or count of product B or Both
Then I can say 30 customers have both

20 has only product A

10 has Product B

I have a customer table with customer Name, CustomerAccount
product table with ProductID, ProductDescription
Something like this

TheresaB_4_0-1704809808185.png

 

I was thinking of first doing a measure then a count.

But I can not seam to get the measure right either
=if(ProductDescription='ProductA' and ProductDescription = 'ProductB' ,  'Dual' , 'Single')


Labels (1)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think

if (Count({<ProductDescription={"ProductA", "ProductB"}>}
Distinct ProductDescription) > 1, 'Dual', 'Single)

-Rob

View solution in original post

6 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think

if (Count({<ProductDescription={"ProductA", "ProductB"}>}
Distinct ProductDescription) > 1, 'Dual', 'Single)

-Rob

TheresaB_4
Contributor III
Contributor III
Author

Thank you Rob, it works now.

TheresaB_4
Contributor III
Contributor III
Author

Can I do this in the Script editor as well?


TheresaB_4
Contributor III
Contributor III
Author

If I want to use this solution as a Dimension rather than a Measure, can I do it.
if (Count({<ProductDescription={"ProductA", "ProductB"}>}
Distinct ProductDescription) > 1, 'Dual', 'Single)

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The syntax for doing this in the script editor would be different. Assume you have already loaded your data into Qlik table named "Facts", the approach may be something like this:

Left Join(Facts)
LOAD
  CustomerAccount,
  if(Count(DISTINCT ProductDescription)> 1, 'Dual', 'Single') as ProductCount
Resident Facts
Where Match(ProductDescription, 'ProductA', 'ProductB')
Group By CustomerAccount;

 

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Yes. Try it.