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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Julien94
Contributor II
Contributor II

How to count customers with sales > 0 in a table

Hi, I want to count customers with sales > 0 by Product type in a table.

I tried Count({<[Customer] = {"=Sum([Sales]) > 0"}>} DISTINCT [Customer]) but it is ko.
This expression ignores the Product type in the table. Customer X is not counted for Product type A

Thank for your help

data :

CustomerProductProduct typeSales
X1A10
X2B-20
Y1A10
Y2B10

 

Result ko :

Product typeCustomers with sales >0
 1
A1
B1
1 Solution

Accepted Solutions
Julien94
Contributor II
Contributor II
Author

finally I got the expected result with this formula :
count(DISTINCT if( aggr( sum(Sales),Customer,[Product type]) >0, Customer))

View solution in original post

4 Replies
Anil_Babu_Samineni

Remove DISTINCT keyword and see?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Julien94
Contributor II
Contributor II
Author

I removed DISTINCT and it is still ko : I have 1 customer for Product type A instead of 2

Anil_Babu_Samineni

Create table as follows and show the result?

Dimension : [Product Type]

Expression : Count(If(Sales>0,Customer))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Julien94
Contributor II
Contributor II
Author

finally I got the expected result with this formula :
count(DISTINCT if( aggr( sum(Sales),Customer,[Product type]) >0, Customer))