# 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.
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")
NOW()
Current timestamp
Also, there's an additional set of functions available for Metrics only: Formula
Meaning
Example
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.