Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Insert excerpt
_Banners
_Banners
nameanalysis
nopaneltrue

info

iconfalsetitle

Scenario

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

Infoiconfalsetitle

Example

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

Solution

There are 2 ways to configure an aggregate

stream

table:

Aggregating on a Pipe

The first method is to put an aggregate attribute(s) on the pipe. This is shown in the

first

screenshot below. When not selected

(as it is in the screenshot),

a pipe with an aggregate attribute will be displayed in blue.

The

pull

pipe from the source to the result

stream

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

stream type of the result stream is 'Aggregate'.The grouping attributes are referred to in the resulting stream by _key[n], where n is the order number for the grouping

example below is grouping on by CustomerName.

The aggregate attribute is referred to by the

pipename

pipe name and its name, e.g. in.

maxAttribute2

InvoiceTotal.

This is the most efficient way of aggregating data with the aggregate

stream

table. However, you will not be able to refer to any attributes in the source

stream

table for which there is no grouping or aggregate attribute. 

Image Removed

Image Added

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

a

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.

Image Removed

The groups could contain multiple entries for BillingAddress, by adding.1 we are telling PhixFlow to take the first one.

Image Added