All CollectionsData TransformationMetrics
How are custom metrics calculated?
How are custom metrics calculated?

Understand more detail on when and how formula and rules are evaluated

Written by Peter Lundberg
Updated over a week ago

Rules are run at the data source level-of-detail (a row-level calculation). One can think of it as a conditional calculation of a new column done per Data Source row.
โ
The results are then aggregated to create the query result. The following aggregation types are supported:

• Sum - add all values to a total

• Count - occurrences per source row

• Min - lowest value per source row

• Max - highest value per source row

• None - does not sum values. What are non-aggregatable metrics?

โFormula are calculated at the visualisation level-of-detail (an aggregate calculation) after summarising. These are also used to calculate totals and can thus also correctly calculate rate and ratios between other metrics.ย

To illustrate this, imagine a simple Funnel Workspace with one Facebook and one Google Analytics account. In this Workspace we have created a custom rule based metric for Cost that uses Spend metric for Facebook and for Google Analytics we multiply any affiliate conversion with 1 dollar. There is also a formula based metric, CPC, that divides the custom Cost with Clicks.

To provide a result showing Cost and CPC per Campaign Funnel would:

1. For Facebook data, apply Cost rules

2. For Google Analytics data, apply Cost rules

3. Summarise data from all data sources per Campaign

4. On the aggregated data apply CPC formula

5. Re-apply CPC formula for totals or other visualisation

Note that formula based metrics in visualisations can not always be calculated in correct order after other formulas are calculated, depending on where this formula is applied. It is therefore not possible to use a formula in another formula. However, since rule based metrics are calculated before formulas they can depend on other aggregatable metrics and be used in formulas.