https://www.growthbook.io/ logo
o

orange-train-515

01/12/2022, 2:46 PM
Hi. I've applied a segment in the experiment analysis settings and trying to figure out how it's applied to the experiment audience. I can see that the segment is joined with the experiment users data but can't see how it's used
Copy code
__distinctUsers as (
  -- One row per user/dimension
  SELECT
    e.user_id,
    'All' as dimension,
    (
      CASE
      WHEN count(distinct e.variation) > 1 THEN '__multiple__'
      ELSE max(e.variation) END
    ) as variation,
    MIN(e.actual_start) as actual_start,
    MIN(e.session_start) as session_start,
    MIN(e.conversion_end) as conversion_end
  FROM
    __experiment e
    JOIN __segment s ON (s.user_id = e.user_id)
  GROUP BY
    dimension,
    e.user_id
),
There's seemingly no reference to the semgent data later on in the query
f

future-teacher-7046

01/12/2022, 2:49 PM
The use of inner join means only users who are part of the segment will be included. We don't actually need any of the columns in that table, just the join is enough.
o

orange-train-515

01/12/2022, 2:50 PM
Oh, sorry. Just noticed there was inner join used. Don't work with it that often so misread it. Thanks
If I understand correctly if user belonged to a certain segment at any point in time, they will be a part of the experiment?
f

future-teacher-7046

01/12/2022, 2:55 PM
yeah, we're not using the timestamp column right now. We probably should be though
o

orange-train-515

01/12/2022, 3:13 PM
That's what I am thinking. Otherwise there can be situations when the user belongs to mutually exclusive segments like "paid" and "not paid". ``````
f

future-teacher-7046

01/12/2022, 4:17 PM
I made a PR to add a WHERE clause for this - https://github.com/growthbook/growthbook/pull/212 Doesn't work when a user goes back and forth between segments (e.g. cancelling a "paid" subscription and going back to "unpaid"). We're still trying to figure out a more general solution to this problem, but the PR should help for basic cases at least.
4 Views