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: 
evas
Contributor
Contributor

countif for 2 values of the same variable

Hi all, 

I am a bit new to Qlik Sense and struggling to create the following: 

 

I have a table with CUSTOMER_ID and ITEM_NAME and I want to know the number of customers that bought two specific articles out of the ITEM_NAME list, lets say "teddy" and "bunny". It is important that the count of customers that I get bought both those items

 

I could not find anything so far in the forum. 

 

Thanks in advance

Labels (2)
3 Replies
Chanty4u
MVP
MVP

Hi try this 

Count({<ITEM_NAME={'teddy'}>} CUSTOMER_ID) * Count({<ITEM_NAME={'bunny'}>} CUSTOMER_ID)

 

evas
Contributor
Contributor
Author

Hi!

Unfortunately this multiplied the number of people where one condition was true times the number of people where the other condition was true and did not give me the number of people where both conditions are true

Chanty4u
MVP
MVP

May be this 

COUNT(DISTINCT {<ITEM_NAME={"teddy","bunny"}>} CUSTOMER_ID)

 

Or

COUNT(DISTINCT {<ITEM_NAME={"teddy"}>} CUSTOMER_ID / {<ITEM_NAME={"bunny"}>} CUSTOMER_ID)