Custom Metric Examples

This applies to: Visual Data Discovery


The following commonly used custom metrics demonstrate custom metric syntax. These examples work with your data source only if your data source contains fields of the same name and type. Change the fields to make them work with your data sources.

The following custom metric is the sum of a metric (totalfatalinjuries) between a specific date (2018-01-01) and the current date:

SUM(totalfatalinjuries) WHERE eventdate BETWEEN '2018-01-01' AND DATE()

in which:

  • totalfatalinjuries can be replaced by your own metric
  • eventdate can be replaced by your own date attribute
  • 2018-01-01 can be replaced by a different specific date

The following aggregated field formula is the sum of a metric (totalfatalinjuries) from the previous period:

SUM(totalfatalinjuries) TRANSFORM eventdate = PreviousPeriod()

in which:

  • totalfatalinjuries can be replaced by your own metric
  • eventdate can be replaced by your own date attribute

The following custom metric produces the difference between the current sum of a metric (totalfatalinjuries) and the sum of the same metric from the previous period:

SUM(totalfatalinjuries) - (SUM(totalfatalinjuries) TRANSFORM eventdate = PreviousPeriod())

in which:

  • totalfatalinjuries can be replaced by your own metric