Using an Aggregate Table

Scenario

You only have one source, but you want to group the data and only pull back aggregated information for each group.

Example

You want to find the earliest entry in a task list.

Solution

There are 2 ways to configure an aggregate table:

Aggregating on a Pipe

The first method is to put an aggregate attribute(s) on the pipe. This is shown in the screenshot below. When not selected a pipe with an aggregate attribute will be displayed in blue.

The pipe from the source to the result table is a pull pipe and has an aggregate attribute on it: InvoiceTotal. You can add a grouping to the pipe if you wish. The example below is grouping on by CustomerName.

The aggregate attribute is referred to by the pipe name and its name, e.g. in.InvoiceTotal.

This is the most efficient way of aggregating data with the aggregate table. However, you will not be able to refer to any attributes in the source table for which there is no grouping or aggregate attribute. 

Aggregating with a Table

If you need flexibility to refer to attributes that are not in the grouping or aggregate attribute list, then do not add an aggregate attribute to the pipe. Instead use an Aggregate Table with aggregate functions in the attribute expressions, such as max(), min(), countElements() and sum() to aggregate the fields. You will then be able to look at all un-aggregated attributes and performs functions such as forEach().

The setup for this second approach is shown in the screenshot below.

Here we are grouping by CustomerName and summing the InvoiceAmount for the group to obtain the InvoiceTotal. We now have access to all attributes so we will retrieve the billing address. The groups could contain multiple entries for BillingAddress, by adding.1 we are telling PhixFlow to take the first one.