Mathematical functions

Several tasks such as Aggregator, Condition, and Notification support a powerful set of mathematical functions:

Most probably you are already familiar with them and used these ones in SQL databases, Microsoft Excel, or Google Spreadsheets.

Array functions

FormulaMeaningExample

AVG(field_name)

Average value in the input data set

AVG(amount)

SUM(field_name)

A sum of values in the input data set

SUM(amount)

COUNT()

Number of rows in the input data set

FIRST(field_name)

First value in the input data set

LAST(field_name)

Last value in the input data set

MAX(field_name)

Max value in the input data set

MAX(amount)

MIN(field_name)

Min value in the input data set

MIN(amount)

Single number functions

FormulaMeaningExample

ROUND(field_name, precision, "floor|ceil")

Round a number up or down with a certain precision

ROUND(tax, 2, "floor")

ABS()

The absolute value of a number

NEG()

Inverts the sign of a number. From "-" to "+" and other way around

SIGN()

Returns:

-1 if d <  0
 0 if d == 0
+1 if d >  0

STRING()

Converts number to string

INT()

Returns an integer part of a decimal number

Other functions

FormulaMeaningExample

ENV()

Use environment variable in a format of ENV_variable_name

ENV_REVENUE_THRESHOLD

NOW()

Current timestamp

INPUT()

The entire input data set as JSON

Metric functions

Also, there's an additional set of functions available for Metrics only:

FormulaMeaningExample

METRIC_AVG("period", duration)

This function returns an average value of this metric within a selected period of time

METRIC_AVG("day", 5) or METRIC_AVG("month", 3) etc.

METRIC_QUANTILE(level, "period", duration)

This function returns a metric quantile within a selected period of time

METRIC_QUANTILE(0.25, "day", 7)

METRIC_MEDIAN("period", duration)

This function returns a median metric value within a selected period of time.

Alias for METRIC_QUANTILE(0.5, "period", duration)

METRIC_MEDIAN("day", 5) or METRIC_MEDIAN("month", 3) etc.

Last updated