Basic functions
The Calculated metrics builder lets you apply statistical and mathematical functions. This article documents alphabetical list of the functions and their definitions.
Table functions versus row functions
A table function is one where the output is the same for every row of the table. A row function is one where the output is different for every row of the table.
Where applicable and relevant, a function is annotated with the type of function: [Table]{class="badge neutral"} or [Row]{class="badge neutral"}
What does the include-zeros parameter mean?
It tells whether to include zeros in the computation. Sometimes zero means nothing, but sometimes it’s important.
For example, if you have a Revenue metric, and then add a Page Views metric to the report, there are suddenly more rows for your revenue, which are all zero. You probably don’t want that additional metric to affect any MEAN, ROW MINIMUM, QUARTILE, and more calculations that you have in the revenue column. In this case, you would check the include-zeros
parameter.
An alternative scenario is that you have two metrics of interest and one has a higher average or minimum because some of the rows are zeros. In that case, you can opt not to check the parameter to include zeros
Absolute Value absolute-value
ABSOLUTE VALUE(metric)
[Row]{class="badge neutral"} Returns the absolute value of a number. The absolute value of a number is the number with a positive value.
Column Maximum column-maximum
COLUMN MAXIMUM(metric, include_zeros)
Returns the largest value in a set of dimension elements for a metric column. MAXV evaluates vertically within a single column (metric) across dimension elements.
Column Minimum column-minimum
COLUMN MINIMUM(metric, include_zeros)
Returns the smallest value in a set of dimension elements for a metric column. MINV evaluates vertically within a single column (metric) across dimension elements.
Column Sum column-sum
COLUMN SUM(metric)
Adds all numeric values for a metric within a column (across the elements of a dimension).
Count count
COUNT(metric)
[Table]{class="badge neutral"} Returns the number, or count, of non-zero values for a metric within a column (the number of unique elements reported within a dimension).
Exponent exponent
EXPONENT(metric)
[Row]{class="badge neutral"} Returns e raised to the power of a given number. The constant e equals 2.71828182845904, the base of the natural logarithm. EXPONENT is the inverse of LN, the natural logarithm of a number.
Mean mean
MEAN(metric, include_zeros)
[Table]{class="badge neutral"} Returns the arithmetic mean, or average, for a metric in a column.
Median median
MEDIAN(metric, include_zeros)
[Table]{class="badge neutral"} Returns the median for a metric in a column. The median is the number in the middle of a set of numbers. That is, half the numbers have values that are greater than or equal to the median, and half are less than or equal to the median.
Modulo modulo
MODULO(metric_X, metric_Y)
Returns the remainder after dividing x by y using Euclidean division.
Examples
The return value has the same sign as the input (or is zero).
MODULO(4,3) = 1
MODULO(-4,3) = -1
MODULO(-3,3) = 0
To ensure you always get a positive number, use
MODULO(MODULO(x,y)+y,y)
Percentile percentile
PERCENTILE(metric, k, include_zeros)
[Table]{class="badge neutral"} Returns the nth percentile, which is a value between 0 and 100. When n < 0, the function uses zero. When n > 100, the function returns 100.
Power Operator power-operator
POWER OPERATOR(metric_X, metrix_Y)
Returns x raised to the y power.
Quartile quartile
QUARTILE(metric, quartile, include_zeros)
[Table]{class="badge neutral"} Returns the quartile of values for a metric. For example, quartiles can be used to find the top 25% of products driving the most revenue. COLUMN MINIMUM, MEDIAN, and COLUMN MAXIMUM return the same value as QUARTILE when quartile is equal to 0
(zero), 2
, and 4
, respectively.
Round round
ROUND(metric, number)
Round without a number parameter is the same as round with a number parameter of 0, namely round to the nearest integer. With a number parameter, ROUND returns the number digits to the right of the decimal. If number is negative, it returns 0’s to the left of the decimal.
Examples
ROUND( 314.15, 0) = 314
ROUND( 314.15, 1) = 314.1
ROUND( 314.15, -1) = 310
ROUND( 314.15, -2) = 300
Row Count row-count
ROW COUNT()
Returns the count of rows for a given column (the number of unique elements reported within a dimension). Uniques exceeded is counted as 1.
Row Max row-max
ROW MAX(metric, include_zeros)
Maximum of the columns of each row.
Row Min row-min
ROW MIN(metric, include_zeros)
Minimum of the columns of each row.
Row Sum row-sum
ROW SUM(metric, include_zeros)
Sum of the columns of each row.
Square Root square-root
SQUARE ROOT(metric, include_zeros)
[Row]{class="badge neutral"} Returns the positive square root of a number. The square root of a number is the value of that number raised to the power of 1/2.
Standard Deviation standard-deviation
STANDARD DEVIATION(metric, include_zeros)
[Table]{class="badge neutral"} Returns the standard deviation, or square root of the variance, based on a sample population of data.
Variance variance
VARIANCE(metric, include_zeros)
[Table]{class="badge neutral"} Returns the variance based on a sample population of data.
The equation for VARIANCE is:
{width="100"}
Where x is the sample mean, MEAN(metric), and n is the sample size.
To calculate a variance, you look at an entire column of numbers. From that list of numbers you first calculate the average. Once you have the average, you go through each entry and do the following:
-
Subtract the average from the number.
-
Square the result.
-
Add that to the total.
Once you have iterated over the entire column, you have a single total. You then divide that total by the number of items in the column. That number is the variance for the column. It is a single number. It is, however, displayed as a column of numbers.
In the example of the following three-item column:
The average of this column is 2. The variance for the column is ((1 - 2)2 + (2 - 2)2 + (3 - 2)2/3) = 2/3.