helpful-glass-76730
03/10/2025, 10:40 AMlate-dentist-52023
03/10/2025, 3:54 PMI guess the only way to go about it is to create the definitions in your fact table query.
That is how we have done it. We put the logic in our data warehouse, though, so that they are persistent rather than recalculated every time the metric is refreshed in some experiment.helpful-application-7107
03/10/2025, 4:02 PMhelpful-glass-76730
03/10/2025, 4:10 PMlate-dentist-52023
03/10/2025, 4:50 PMid
column you can join on (user, session, etc).
Join a
to b
on id
where a.timestamp
< b.timestamp
and datediff('seconds', a.timestamp, b.timestamp) < xxxx
where xxxx
is relevant to your business case, similar to a conversion window, you allow a certain amount of time to pass for the second event. You will also need to think about handling the case of users who never do action b
as that is going to be null or infinite time, might be a second metric that is proportion of users who do a -> b within xxxx
that you could also build.
Since a user might be able to do b
multiple times after a
take the minimum difference between a.timestamp
and b.timestamp
that are in that join for each a
event. If you need to further deduplicate (i.e. they could do action b
multiple times quickly) you can also use a window function like row_number() to ensure you only get the first record. There are other ways to accomplish this only first record ordered by smallest time difference depending upon what data warehouse you are using etc.
In the end that gives you one record for each a
table entry that is the first time the user did b
after a
within some defined conversion window.helpful-glass-76730
03/10/2025, 5:11 PM