Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
nbazz
Contributor II
Contributor II

Help with p() and intersection

Hello!

I need to get the user id of people who did the event A and the event B. I'm having trouble using p() and intersection.

First problem: p()

If I use count({$<event_name={'A'}>}distinct user_id)

the result is 500, which is the correct answer (doublecheck in databricks)

But if I use count({$<user_id=P({<event_name={'A'}>}user_id)>}distinct user_id)

the result I get is 1.17K. 

Second problem: p() and *

So, before I got two different answers: 500 and 1.17k. If I use count({$<user_id=P({<event_name={'A}>}user_id)*P({<event_name={'B'}>}user_id)>}distinct user_id)

I get 1.09k, which is wrong since it's bigger than 500.

Things that also didn't work:

count({$<user_id=P({<event_name={'A}>}user_id)*P({<event_name={'B'}>}user_id), event_name={'A','B'}>}distinct user_id)

count({$<user_id=P({<event_name={'A}>}user_id)>*<user_id=P({<event_name={'B'}>}user_id)>}distinct user_id)

count({<event_name={'A'}>}user_id) * count({<event_name={'B'}>}user_id)

1 Solution

Accepted Solutions
PrashantSangle

Hi,

Try below

For 1st Query

1: Count({<event_name={'A'}>} distinct user_id)

for intersection 

1: Count({<event_name={'A'}>*<event_name={'B'}>} distinct user_id)

2: Count({<event_name={'A'}>} distinct user_id) + Count({<event_name={'B'}>} distinct user_id)

 

I don't understand, Why you need p() over here?

If you want to see all user_id where event_name=A regardless any selection then use 1 instead of $

 

Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

5 Replies
sasikanth
Master
Master

HI, 

try below expression:

count( DISTINCT {$<user_id=P({<event_name={'A'}>} ) *P({<event_name={'B'}>} )  >} user_id)

 

Thanks, 

Sasi

nbazz
Contributor II
Contributor II
Author

Hi @sasikanth , thanks for replying.

Unfortunately, it also doesn't work. The codes I was trying to use also have distinct, just before the user_id, so it's not that the problem.

sasikanth
Master
Master

can you check the result for below expression

count( DISTINCT {$<user_id=P({<event_name={'A'}>} ) >} user_id) 

PrashantSangle

Hi,

Try below

For 1st Query

1: Count({<event_name={'A'}>} distinct user_id)

for intersection 

1: Count({<event_name={'A'}>*<event_name={'B'}>} distinct user_id)

2: Count({<event_name={'A'}>} distinct user_id) + Count({<event_name={'B'}>} distinct user_id)

 

I don't understand, Why you need p() over here?

If you want to see all user_id where event_name=A regardless any selection then use 1 instead of $

 

Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
nbazz
Contributor II
Contributor II
Author

Thank you, @PrashantSangle , it worked!