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: 
Not applicable

How to get the nums?

Hi All,

I have the following table.

load * Inline
[
CountMemberId,Category
1,A
1,A
2,C
2,A
3,A

]

I want to use an expression to show how many members have bought at leaset 2 products whose category is A.

For this test, only one whose ID is 1.

How to finish it?

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hello,

Use

Count({< CountMemberId = {"=Count({< Category = {'A'} > + < Category = {'C'} >} CountMemberId) > 1"} >} DISTINCT CountMemberId)


That will return "1" for those CountMemberId who have bought either 2 "A" or 2 "C".

Hope that helps.

View solution in original post

3 Replies
Miguel_Angel_Baeyens

Hello Isaac,

I'd use something like

Count({< CountMemberId = {"=Count({< Category = {'A'} >} CountMemberId) > 1"} >} DISTINCT CountMemberId)


Hope that helps.

Not applicable
Author

Yes, it works, you are always my teacher.

Now I have an additional question on it.

If I want to get the nums who bought at least 2 product A or at least 1 product C, how to use set analysis, in this case, 1 have bought 2 A and 2 have bought 1 C, so the result is two, how to finish it?

Thanks Miguel Angel Baeyens.

Miguel_Angel_Baeyens

Hello,

Use

Count({< CountMemberId = {"=Count({< Category = {'A'} > + < Category = {'C'} >} CountMemberId) > 1"} >} DISTINCT CountMemberId)


That will return "1" for those CountMemberId who have bought either 2 "A" or 2 "C".

Hope that helps.