Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
confused-pandas
Contributor II
Contributor II

Count distinct IDs having at least 2 entries per week

Hi,

I have a data set composed of Users and Sessions. What I want to do is create a measure that returns the number of users with at least N sessions on every week. So far I have this for N = 2 but I am missing the part where I indicate that the condition needs to be true for each week:

count({<userId = {`=count(sessionId)>=2`}>} distinct userId)

Any idea how I can achieve this using set analysis

Labels (2)
2 Replies
micheledenardi
Specialist II
Specialist II

I tried with this dataset:

load * inline [
WeekNo,UserID,sessionId
1,Usr1,session1
1,Usr2,session2
2,Usr2,session3
3,Usr1,session4
3,Usr2,session5
3,Usr2,session6
4,Usr3,session7
5,Usr3,session8
5,Usr3,session9
5,Usr3,session10
];

And using this expression:

Count(Distinct aggr(count(Distinct {<UserID = {`=count(sessionId)>=2`}>} distinct UserID),WeekNo))

And the result is correct:

2021-10-12 15_01_37-test - Il mio nuovo foglio (23) _ Foglio - Qlik Sense.png

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
confused-pandas
Contributor II
Contributor II
Author

Thank you Micheledenardi for your help. I believe you are measuring the number of times any user had at least 2 sessions on a week. What I am trying to calculate is the number of users with at least 2 sessions on EVERY week. Here is an example with a modified version of your data set:

 

LOAD * INLINE [
WeekNo,UserID,sessionId
1,Usr1,session1
1,Usr2,session2
1,Usr2,session3
2,Usr1,session4
2,Usr1,session5
2,Usr2,session6
2,Usr2,session7
2,Usr3,session8
3,Usr2,session9
3,Usr2,session10
4,Usr2,session11
4,Usr2,session12
4,Usr3,session13
4,Usr3,session14
];

 

In the data set below, Usr2 is the only user with at least 2 sessions on every week (week 1, 2, 3 & 4). Therefore, the count of distinct users here is 1.