Aggregate data
The Aggregate data action node is used to perform aggregations on data in Data connectors. It is available in Apps, Services and Flows.
Usage
This action node can be used when large amounts of data in the database should be aggregated (counted, summarized, averaged etc.) on database-level, i.e. without reading all the records to the Apps or Services client. You may filter and group the records being aggregated.
Aggregate data is suitable, for example, for Dashboards or Search pages where you want to display counts or summaries that span huge sets of data records.
Aggregating large data sets can take time, and every aggregation is subject to a time limit on the database. If your aggregation fails because it exceeds this limit, contact Appfarm support about the Data Aggregation Service add-on, which runs aggregations on dedicated analytics infrastructure with a longer time limit.
Permissions
The role that runs Aggregate data needs the Aggregate permission on the object class behind the Data connector. Aggregate is granted separately from Read, so Read alone is not enough: without Aggregate, the action node fails with a permission error.
An aggregation can return whole objects, not only counts and sums. Grant Aggregate only to roles that may read the data.
Nested properties
By default, you can group by and aggregate on properties that belong directly to the object class behind the selected Data connector. The Data Aggregation Service add-on additionally lets you group by and aggregate on nested properties: properties on related object classes, reached by following a reference.
For example, with a data connector of Orders you can group by the Region of each Order's related Customer, written as Order.Customer.Region. References can be followed through multiple levels, so you can also aggregate on a property several references away, such as Customer.Account.Tier.Price.
Nested properties are selected the same way as anywhere else you bind data. In the Property selector of a Group by item or an aggregation, select a reference property to open the related object class, then choose the property to use. Repeat to follow references through several object classes.
Examples
In this example, no groupings or filters are applied. The chosen operator is Count, and the value should be written to the Count property of the Target. Note that the Count operator has no property to aggregate by. The result is one object in the data source Order aggregates (temp) with Count equal to the total number of Orders.

In this example, the Orders are grouped by the Customer property. The Customer value is written to the Customer property of the Target. The chosen operator is Average, and the property to aggregate by is the Amount of each Order. The value should be written to the Average property of the Target. This will create one object for each unique Customer that is represented in the Orders Data Connector. The objects are stored in the data source Order aggregates (temp) with Average equal to the average Order Amount for that customer.

In this example, the Orders are grouped by the Customerand Status properties. The Customer and Status values are written to the Customer and Status properties of the Target. The chosen operator is Sum, and the property to aggregate by is the Amount of each Order. The aggregation result should be written to the Sum property of the Target. This will create one object for each unique combination of values of Customer and Status that are present in the Orders Data Connector. The objects are stored in the data source Order aggregates (temp) with Sum equal to the sum of Order Amounts for that combination of Customer and Status.

Properties
Data connector
Select a data source of type data connector to perform aggregations on. Only many-cardinality data connectors are listed.
Selection
Define the objects to aggregate.
All objectsFiltered selection
Filter
Available when Filtered Selection is selected.
Define the filter to apply to the data connector.
Conditional filters
Add filters that can be enabled or disabled runtime. All enabled filters will be applied in addition to the regular filter.
Sorting
Add sorting rules. The objects will be sorted before the grouping and aggregations are performed.
Target
Specify a runtime-only data source to place the resulting data in. This includes App Variables, Action Variables and service variables.
Operation
Select how existing objects in the Target will be treated. The options depend on the cardinality of the Target.
Many-cardinality target:
Replace all objects(default): Remove any existing objects before creating the objects.Add objects: Keep any existing objects and add the new ones. Objects are not merged.
Single-cardinality target:
Replace object(default): Replace the existing object.Update single cardinality object: Update the selected property in the existing object.
If the Target is App Variables, Action Variables or a service variable, the operation is locked to Update single cardinality object.
Group by
Only available if the Target is many-cardinality.
Optionally select one or more properties to group the data by and which property to write the group value to. This will create one aggregation per unique value of the selected property, and thus create multiple objects in the Target. Each grouping item has these properties:
Property: select which property to group the data by
Resolution: only available if the selected property is of type Datetime. Select which time resolution to group by:
None (Datetime),Day of Month (1-31),Day of Week (ISO, 1-7),Hour (0-23),Minute (0-59),Second (0-59),Month (1-12),Week Number (ISO)orYear.Value: choose which property in the Target to write the grouping value to.
Aggregations
Add aggregations.
Each aggregation has these properties:
Enabled: databind to a boolean value or set up a condition or function to enable or disable runtime. Default is
trueOperator: select which operator to apply in the aggregation, see the list of available operators below
Property: select which property to perform the aggregation on. Hidden for
Count.Value: select which property in the Target to write the aggregated value to
Aggregation Operators
Count
Returns the number of objects. It has no Property to select.
Sum
Returns the sum of the values of the selected property.
Average
Returns the average value of the values of the selected property.
Max
Returns the maximum value of the selected property.
Min
Returns the minimum value of the selected property.
Population Standard Deviation
Calculates the population standard deviation of the values of the selected property. Use if the values encompass the entire population of data to be represented. Read more at https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/
Sample Standard Deviation
Calculates the sample standard deviation of the values of the selected property. Use if the values encompass a sample of a population of data from which to generalize about the population. Read more at https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/
First
Returns the first value of the selected property.
Last
Returns the last value of the selected property.
Last updated
Was this helpful?