DataJunction / dj

A metrics platform.
http://datajunction.io
MIT License
35 stars 15 forks source link

calculated / derived metrics #654

Open shangyian opened 1 year ago

shangyian commented 1 year ago

This needs way more discussion, but putting this as an issue so that I remember.

We can have a calculated/derived metric that's composed of one or more regular metrics and stitched together by an expression of those metrics. These regular metrics still have to abide by the same rules as before -- i.e., they should be an aggregation with a single result column.

image

In the example above, the regular metrics are views, defined as SELECT SUM(views) FROM B, and signups, defined as SELECT SUM(signups) FROM A. Then they can be composed in various ways to form a derived metric - in the example above, the composing is defined by the expression signups / views to form a ratio.

There will have to various rules on this type of derived metric to make sure that (a) they are always operating on the same level and (b) that they share dimensions and specifically share all required dimensions.

shangyian commented 1 year ago

@samredai You should also put your metric templating idea up in an issue! I think you had a nice diagram

samredai commented 1 year ago

@shangyian I'm worried if I create the issue we might actually do it 😭