Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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:
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.