Mathematical functions and operations
Last updated
Last updated
Several tasks such as Aggregator, Condition, and Notification are empowered by an extended mathematical editor that supports a powerful set of mathematical functions and operations.
Most probably you are already familiar with them and used these ones in SQL databases, Microsoft Excel, or Google Spreadsheets.
Also, there's an additional set of functions available for Metrics only:
The following list is supported:
+ - / * % **
== === != !== > < >= <= >== <==
|| && !
| & ^ << >>
The following two operations are supported for searching in strings with regular expressions
=~ // means a regular expression match is found !~ // means a regular expression match is not found
For example, the following string placed in the Condition or Aggregator will return true
Supported syntax for regular expressions: https://pkg.go.dev/regexp/syntax.
Comparison operations can also be used for comparing dates. The following formats are supported:
time.UnixDate,
time.RubyDate,
time.Kitchen,
time.RFC3339,
time.RFC3339Nano,
"2006-01-02", // RFC 3339
"2006-01-02 15:04", // RFC 3339 with minutes
"2006-01-02 15:04:05", // RFC 3339 with seconds
"2006-01-02 15:04:05-07:00", // RFC 3339 with seconds and timezone
"2006-01-02T15Z", // ISO8601 with hour without UTC offset
"2006-01-02T15:04Z", // ISO8601 with minutes without UTC offset
"2006-01-02T15Z0700", // ISO8601 with hour
"2006-01-02T15:04:05Z", // ISO8601 with seconds without UTC offset
"2006-01-02T15:04Z0700", // ISO8601 with minutes
"2006-01-02T15:04:05Z0700", // ISO8601 with seconds
"2006-01-02T15:04:05.999999999Z", // ISO8601 with nanoseconds without UTC offset
"2006-01-02T15:04:05.999999999Z0700", // ISO8601 with nanoseconds
Formula | Meaning | Example |
---|---|---|
Formula | Meaning | Example |
---|---|---|
Formula | Meaning | Example |
---|---|---|
Formula | Meaning | Example |
---|---|---|
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)
ROUND(field_name, precision, "floor|ceil")
Round a number up or down with a certain precision
ROUND(tax, 2, "floor")
ABS(field_name)
The absolute value of a number
NEG(field_name)
Inverts the sign of a number. From "-" to "+" and other way around
SIGN(field_name)
Returns:
STRING(field_name)
Converts number to string
INT(field_name)
Returns an integer part of a decimal number
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_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.