Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Josh
Contributor II
Contributor II

Using P in Set Analysis

Hey community,

Scenario:

I have a website that shows videos. Before entering the video, there is a pretest. 

I am trying to find the amount of people who took the pretest and watched the segment. (I can't use an "if" statement as the fields are from different databases and the numbers come all messed up). I am trying to use the possible P into the equations and it has yet to work for me. 

 

The fields are session_id,  quiz_type, and event_type. 

Once again I need the count of distinct session_id's that took the pretest (quiz_type = 1) and played the video (event_type=33,34,35). 

This is the code I tried. 

Count(${<session_id = P({<event_type={33,34,35}, quiz_type = {1} >} distinct session_id)>} distinct session_id)

It actually produces the same result as 

Count( distinct session_id)

which means something is wrong in here ${<session_id = P({<event_type={33,34,35}, quiz_type = {1} >} distinct session_id)>}

 

Any help is greatly appreciated!

 

Labels (2)
7 Replies
y_grynechko
Creator III
Creator III

Hey, can you share some data sample? 

Josh
Contributor II
Contributor II
Author

Capture33.PNG

So there are two tables with session_Id being the primary keys. 

sunny_talwar

What is the expected count of sessions id based on the input shared?

Josh
Contributor II
Contributor II
Author

Capture33.PNG

For this particular example: the output for distinct session_id should be 3. Because A,B,and C all have a 1 for a quiz type and at least 1 of the 3 required event_types (33,34,35). 

sunny_talwar

Your expression with small modifications give me 3

Count({$<session_id = P({<event_type = {33,34,35}, quiz_type = {1}>} session_id)>} DISTINCT session_id)

1) Note that $ comes after { and not before

2) DISTINCT is not needed within the p() function 

Josh
Contributor II
Contributor II
Author

Sunny,

Unfortunately that didn't work....it gives me 0. 

However, with some trial and error over the past few hours we have this now that seems to work....BUT I would appreciate feedback on what people think of this new formula. Just want to see if it seems sound as I am not used to using *. 

=count( {< session_id = p( {<quiz_type={1}>} ) * p( {<event_type={33,34,35}>} ) >} distinct session_id)

 

sunny_talwar

Did you open the .qvf file and not seeing this?

image.png