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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
sifatnabil
Specialist
Specialist

Set analysis and operator

Hi all,

I would like to count the distinct number of sessions where trader A and B both participated on a Tuesday. Should the set analysis look like this?

count({<SessionId = p({<[TraderName] = {'Mark'}>}) * p({<[TraderName] = {'Bob'}>}),Day={'Tues'}>} distinct SessionId)

1 Solution

Accepted Solutions
sunny_talwar

What about this:

Count({<SessionId = p({<[TraderName] = {'Mark'}, Day={'Tues'}>}) * p({<[TraderName] = {'Bob'}, Day={'Tues'}>})>} distinct SessionId)

View solution in original post

9 Replies
tresesco
MVP
MVP

May be like:

count({<[TraderName] = {'Mark'},Day={'Tues'}> *<[TraderName] = {'Bob'}>},Day={'Tues'}>} distinct SessionId)

sunny_talwar

What about this?

Count({<SessionId = p({<[TraderName] = {'Mark', 'Bob'}, Day={'Tues'}>})>} distinct SessionId)

sifatnabil
Specialist
Specialist
Author

Hi sunindia‌, this is close, but it's doing Mark OR Bob. How can we make it count sessions for Mark AND Bob ?

sunny_talwar

tresesco‌ expression did not work as well?

sifatnabil
Specialist
Specialist
Author

Yes, that one seems to return zero.

sunny_talwar

What about this:

Count({<SessionId = p({<[TraderName] = {'Mark'}, Day={'Tues'}>}) * p({<[TraderName] = {'Bob'}, Day={'Tues'}>})>} distinct SessionId)

kkkumar82
Specialist III
Specialist III

I think it would be better to create a sample either by some one to see the results

sifatnabil
Specialist
Specialist
Author

Thanks, I just checked the data and it looks like both these variations work:

count({<SessionId=p({<[TraderName] = {'Bob'},Day={'Tue'}>})*p({<TraderName={'Mark'},Day={'Tue'}>})>}distinct SessionId)

OR

count({<SessionId = p({<[TraderName] = {'Bob'}>}) * p({<[TraderName] = {'Mark'}>}),Day={'Tue'}>} distinct SessionId)

Any idea why tresesco's doesn't work? Is it because TraderName itself cannot be 2 different names simultaneously?

sunny_talwar

Yes, you are right, a single row of data cannot have both TraderName on it. But a single SessionId can have multiple rows where one contains Mark and other contains Bob. He might have forgot to add SessionId and the p.