Aggregation Functions

Last update: 2023-01-26
  • Created for:
  • Experienced
    Developer

Aggregation functions are used to group together multiple values to form a single summary value.

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

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

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

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

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)%}

On this page