Aggregation functions

Aggregation functions are used to group together multiple values within Profile Query Language (PQL) arrays to form a single summary value. More information about other PQL functions can be found in the Profile Query Language overview.

Count

The count function returns the number of elements within the given array as a number.

Format

{ARRAY}.count()

Example

The following PQL query returns the number of orders in the array.

orders.count()

Sum

The sum function returns the sum of all the selected values within the array as a number.

Format

{ARRAY}.sum()

Example

The following PQL query returns the sum of all the orders’ prices.

orders.sum(order.price)

Average

The average function returns the arithmetic mean of all the selected values within the array as a number.

Format

{ARRAY}.average()

Example

The following PQL query returns the average price of all the orders.

orders.average(order.price)

Minimum

The min function returns the smallest of all the selected values within the array as a number.

Format

{ARRAY}.min()

Example

The following PQL query returns the lowest price of all the orders.

orders.min(order.price)

Maximum

The max function returns the largest of all the selected values within the array as a number.

Format

{ARRAY}.max()

Example

The following PQL query returns the highest price of all the orders.

orders.max(order.price)

Next steps

Now that you have learned about aggregation functions, you can use them within your PQL queries. For more information about other PQL functions, please read the Profile Query Language overview.

recommendation-more-help
770bc05d-534a-48a7-9f07-017ec1e14871