# App Development

Announcements
April 22, 2PM EST: Learn about GeoOperations in Qlik Sense SaaS READ MORE
cancel
Showing results for
Did you mean:
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)

• ### Set Analysis

7 Replies
Creator III

Hey, can you share some data sample?

Contributor II
Author

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

MVP

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

Contributor II
Author

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).

MVP

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

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)

MVP

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

Tags