Let’s say we have records of user milestones:
user_id | event_a | event_b | event_c | …
1 | time_a | time_b | time_c | …
We’d like users to be able to calculate differences between two arbitrary event times on the fly, as well as measures on them. For example, answering the question “What is the average time elapsed between event_x and event_y for a user?” for arbitrary x and y.
Short of hard-coding dimensions for all n^2 pairs of events, is there a way to enable this?
Great question! You can definitely accomplish the on-the-fly part of this with table calculations. You’d just need to pull in the milestone time fields and do a date diff between them. You could also use another table calc to do additional aggregations like avg on that list of time diffs, however the avg calculation would show up in every row of your result set.
At the moment we don’t have a great way to do this in lookml, but if you don’t have too many milestones you could write dimensions for date diffs between each one and if you had a need to explore time between event_1 and event_6 for example you could write another dimension that adds 1-6. We’re happy to discuss either approach more here or on chat!
Well, there is a way you can solve this. It is undocumented because we really don’t like the user interface it presents so we are going to make a new and better way for this to work in the future. There is enough code lying around using this construct that we’ll continue to support it.
Will produce an explore that works like: