Skip to main content

Call Aggregate Function

  Aggregate functions are used to process collections of data (such as arrays or objects) to compute summary values like sums, averages, counts, min, max or other aggregate results. These functions typically iterate over elements in an array and perform computations based on a given logic.

These Functions simplify manipulation, processing and performing calculations on arrays.

The following is a list of aggregate functions:

  1. Find
  2. FindAll
  3. RemoveAll
  4. Remove
  5. Sort
  6. Average
  7. Sum
  8. Count
  9. Min
  10. Max

Steps to configure Call Aggregate Function Construct​

  1. Open the designer canvas of a logic flow, drag and drop the Call Aggregate Function construct into the flow.
  2. Double-click the construct to configure the properties as required and then click Save.

Properties​

PropertyDescriptionComments
LabelLabels help developers quickly understand each step in the logic flow without examining the details of the construct.It is recommended to provide a simple precise label that can improve the readability.
Aggregate Function*Select required function from list.Following are the list of functions: Find FindAll RemoveAll Remove Sort Average Sum Count Min Max
Input*Specify the input array.A collection (e.g., array or list) containing objects.
Current Item*Specify the element to apply conditions on.Acts as a placeholder for each item in the Input during processing.
Property*Specify the property name from the attribute list of the current item property on which the aggregate function will be executed.This field is visible for Sum, Average, Sort, Min, Max in Complex Collections.
ConditionSpecify Filter condition (optional).Filters the collection to include only items meeting this criterion. Use the expression builder
Output*Specify a variable to store the result.Specifies in which format the data needs to be stored.
CommentSpecify whether to comment this construct or not. Either Yes or No.If marked as Yes, the construct is treated as a commented expression and ignored in code generation.
DescriptionProvides details about the Aggregate function purpose and behaviour.Helps in understanding the selected aggregate function.

Examples​

Example 1: Counting Items in a List

Scenario: You have a list of orders and want to count how many orders exist.

  • Aggregate Function: Count()
  • Input: Orders (a list of order objects)
  • Output: var totalOrders

Result: The total number of orders is stored in totalOrders.

Example 2: Finding the Maximum Value in a List

Scenario: You have a list of products and want to find the highest price.

  • Aggregate Function: Max()
  • Input: Products (a list of product objects)
  • Property: Price
  • Output: var maxPrice

Result: The highest price in the product list is stored in maxPrice.

Example 3: Finding the Minimum Value in a List

Scenario: You have a list of products and want to find the lowest price.

  • Aggregate Function: Min()
  • Input: Products (a list of product objects)
  • Property: Price
  • Output: var minPrice

Result: The lowest price in the product list is stored in minPrice.

Example 4: Sorting a List of Names

Scenario: You have a list of employee names and want to sort them alphabetically.

  • Aggregate Function: Sort()
  • Input: EmployeeNames (a list of strings)
  • Order: Ascending/Descending
  • Output: var sortedNames

Result: The sorted list is stored in sortedNames.

Example 5: Sum of Values in a List

Scenario: You have a list of products and want to get the total amount.

  • Aggregate Function: Sum()
  • Input: Invoices (a list of product objects)
  • Property: Price
  • Output: var totalPrice

Result: The total sum of all invoices is stored in totalPrice.

Example 6: Finding Orders with a Specific Customer and Status

Scenario: You want to retrieve all orders that are marked as "Pending".

  • Aggregate Function: FindAll()
  • Input: Orders (a list of order objects)
  • Property: Status
  • Condition: Status == "Pending"
  • Output: var pendingOrders

Result: The list of pending orders stored in pendingOrders.

Example 7: Calculating the Average Salary

Scenario: You have a list of employees and want to calculate the average salary.

  • Aggregate Function: Average()
  • Input: Employees (a list of employee objects)
  • Property: Salary
  • Output: var avgSalary

Result: The average salary is stored in avgSalary.

Example 8: Removing a Specific Employee

Scenario: You have a list of employees and want to remove an employee with a specific Id.

  • List Function: Remove()
  • Input: Employees (a list of employee objects)
  • Current Item: emp.
  • Condition: emp.Id == 104

Result: The employee with ID 104 is removed from the list.

Example 9: Removing All Employees from a Specific Department

Scenario: You have a list of employees and want to remove all employees in the "Sales" department.

  • List Function: RemoveAll()
  • Input: Employees (a list of employee objects)
  • Condition: Department == "Sales"

Result: All employees from the "Sales" department are removed from the list.