3 Replies Latest reply: Feb 29, 2016 3:04 PM by Stefan Wühl

# Set analysis - given a subset of users, count users

I'm looking to write a set analysis that counts a number of users from a subset of users.

Here's the data I'm working with:

MaxScroll only populates if HitType is 'Scroll'

UserIdPageHitTypeMaxScroll

1

www.blah.com/blah1Scroll0
2www.blah.comScroll0.25
2www.blah.comClick-
3www.blah.com/blah2Scroll0.50
4www.blah.com/blahScroll0.75
4www.blah.com/blahClick-
5www.blah.com/blah3Scroll0.25

I need to count UserId's of users who scrolled more than 0, and who also clicked.

count({<HitType = {Scroll, Click}, MaxScroll -= {0}>}distinct UserId) does not work, since MaxScroll is null in cases of 'Click' HitType, so it returns 0.

Basically I need users who scrolled over 0 (easy =count({<HitType = {Scrolling}, MaxScroll -= {0}>}distinct UserId)) and of those users how many clicked. I'm not sure how to go about doing this.

• ###### Re: Set analysis - given a subset of users, count users

Maybe like

=Count({<UserId = p({<HitType = {Scrolling}, MaxScroll -= {0}>})*p({<HitType = {Click}>}) >} DISTINCT UserId)

• ###### Re: Set analysis - given a subset of users, count users

That worked, thanks!

Would you mind explaining why that worked? I've read about the p() function, but I'm not sure how it's working in this case.

• ###### Re: Set analysis - given a subset of users, count users

You probably know the white / green / grey colors in QV list boxes.

The p() functions work like retrieving the white colored UserID when you make selections HitType = {Scrolling}, MaxScroll -= {0} resp. HitType = {Click}. So you are retrieving two sets for UserID, then intersect these two sets using the intersection operator *.

Basically it's just translating your requirement

"Basically I need users who scrolled over 0 (easy =count({<HitType = {Scrolling}, MaxScroll -= {0}>}distinct UserId)) and of those users how many clicked. I'm not sure how to go about doing this."

into QV syntax: