Aggregation Functions aggregation
Aggregation functions are used to group together multiple values to form a single summary value.
Average average
The average
function returns the arithmetic mean of all the selected values within the array.
Syntax
{%= average(array) %}
Example
The following operation returns the average price of all the orders.
{%=average(orders.order.price)%}
Count count
The count
function returns the number of elements within the given array.
Syntax
{%= count(array) %}
Example
The following operation returns the number of orders in the array.
{%= count(orders) %}
Maximum max
The max
function returns the largest of all the selected values within the array.
Syntax
{%= max(array) %}
Example
The following operation returns the highest price of all the orders.
{%=max(orders.order.price)%}
Minimum min
The min
function returns the smallest of all the selected values within the array.
Syntax
{%= min(array) %}
Example
The following operation returns the lowest price of all the orders.
{%=min(orders.order.price) %}
Sum sum
The sum
function returns the sum of all the selected values within the array.
Syntax
{%= sum(array) %}
Example
The following operation returns the sum of all the orders’ prices.
{%=sum(orders.order.price)%}