Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
...
...
Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
By the end of this chapter you will be able to:
Table of Contents
You will also learn how to
...
pass only some records to the receiving table using the Maximum Number of Records per Group option.
In this exercise you will select the
...
most recent
...
sales record for each customer
...
from the set of combined updates you created in the previous exercise.
Create an aggregate
...
table
In PhixFlow, we use an aggregate table to show that we are rearranging data from a single table. See the reference page Aggregating Data for details.
- From the model toolbar,
...
- drag
Insert excerpt _
...
table_aggregate _
...
table_aggregate nopanel true
...
- into the model.
- Set the
...
- table Name to
Latest Package Update
. - Add a pipe from
Combined Updates
:- Hover your mouse pointer over the
...
- table
Combined Updates.
- In the context toolbar, click
Insert excerpt
- table
...
_pipe
...
._pipe nopanel true - Click the
...
- table
Latest Package Update
to connect the pipe. - PhixFlow opens the pipe settings. Click
to close the settings.Insert excerpt _finish _finish nopanel true
- table
- Drag all attributes from
Combined Updates
toLatest Package Update
.- Hover your mouse pointer over the
...
- table
Combined Updates
- table
...
- .
- In the context toolbar, click
Insert excerpt _
...
attributes _
...
.attributes nopanel true
...
- PhixFlow lists the data attributes (column titles) for this
...
- table.
- Select all the attributes and drag them into the
Latest Package
...
Update table
.
Image Added
- In the
Channel Package
model toolbar, click
.Insert excerpt _save _save nopanel true
When you next run this model, the Latest Package Updates
...
table will pull in all the data from the Combined Updates
...
Group and order data on an input pipe
...
table. At the moment the data will come into the aggregate
...
table in any order.
...
In PhixFlow you can sort the data as it comes through the input pipe to the aggregate
...
table. You can also choose to add specific records to the receiving table.
Group and order data on an input pipe
In PhixFlow, as data records are passed through the model, you can rearrange the records or select records that meet certain criteria. You can do this using options on the table or options on the pipe. In this section you will use options on the pipe to pass one record per customer to the receiving table. That record will be the most recent one for the customer. To achieve this you will:
- group the data, so that all the records with the same
Customer Ref
number are grouped into adjacent rows in the table.
...
- sort the data
...
- from the newest to
...
- the oldest
Sales Date
. This means that the first record delivered by the input pipe, for each Customer Ref, is the most recent for that customer.
...
- pass only the first record per customer record to the receiving table.
- In the model, double-click on the pipe from the
Combined Updates
...
- table.
- Expand the Sort/Group section toolbar.
- In the section toolbar, click
Insert excerpt _
...
attributes _
...
attributes nopanel true
...
- . Phixflow opens a list of the attributes
...
- that the
Combined Updates
table can pass to the pipe. - Drag in
CustomerRef
. By default,
...
- this attribute has Group ticked and Direction set to A-Z (ascending).
This means the data records will be grouped byCustomerRef
. - Drag in
SalesDate
.
...
- Double-click on
SalesDate
in the Sort/Group grid
...
- . PhixFlow opens the settings for the attribute. In Basic Settings, set:
- Direction: Z-A (descending)
- Direction: Z-A (descending)
...
- Group:
Insert excerpt _check_box_untick _check_box_untick nopanel true - Click
to save the change and close the attribute settings.Insert excerpt _finish _finish nopanel true
- Group:
...
- This means the data records will be sorted by date, with the most recent first.
- In the pipe settings → Sort/Group section, set Maximum Number of Records per Group to 1.
This means PhixFlow will pass only one record, the first and therefore most recent, to the receiving table. - Click
Insert excerpt _
...
save _
...
to savesave nopanel true
...
- the pipe settings
...
This setting means that for each key value – in this case for each value of CustomerRef
– only the first record will be returned; since you have also ordered by SalesDate
descending, this will be the latest (most recent) record for each CustomerRef
This is effectively filtering out old records for the same customer.
Test your new Stream
...
- , which should look like this:
Image Added - In the model toolbar, click
to save the model.Insert excerpt _save _save nopanel true
Now you can run the model and view the table data.
- Hover your mouse pointer over the
Latest Package Update
table and click
then click YES to confirm.Insert excerpt _run_analysis _run_analysis nopanel true - When PhixFlow notifies you that the analysis is finished, hover your mouse pointer over the
Latest Package Update
table again. - Click
.Insert excerpt _view_show _view_show nopanel true - In the drop-down list, select
. PhixFlow displays the data.Insert excerpt _view_default _view_default nopanel true
Image Added
Notice that there is only one record per customer reference. - If you also look at the default view for the
Combined Updates
table, you will see that some customers, such as C056 have more than one record. The most recent record has been passed to theLatest package Update
table.