By the end of this chapter you will be able to:
...
- In the repository browser, expand the list of Datasources.
- Drag the datasource called
Rating and Billing
into your model. - In your model, hover your mouse pointer over
Rating and Billing
and click Insert excerpt |
---|
| _tables |
---|
| _tables |
---|
nopanel | true |
---|
|
. PhixFlow displays a list of the tables available in this database. You can resize the list to make it easier to browse. - Right-click on
SOURCE_PACKAGE_CHANNELS
and select Insert excerpt |
---|
| _create_collector |
---|
| _create_collector |
---|
nopanel | true |
---|
|
. PhixFlow adds a new database collector to the model, and gives it the same name as the source data table, SOURCE_PACKAGE_CHANNELS
. In the settings → property tab → Basic Settings section → Statement Expression, you can see the database query is:
select * from SOURCE_PACKAGE_CHANNELS
. - Hover your mouse pointer over the new database collector, and click
Insert excerpt |
---|
| _stream_with_attributes |
---|
| _stream_with_attributes |
---|
nopanel | true |
---|
|
. PhixFlow adds a new stream to your model and also gives it the name SOURCE_PACKAGE_CHANNELS
. In the settings → property tab → Attributes section, you can see that the data has two attributes (columns): Package and Channel. To load the data into the stream, run analysis on this section of the model and check the data has loaded.
Expand |
---|
|
- Hover your mouse pointer over the
SOURCE_PACKAGE_CHANNELS stream , click Insert excerpt |
---|
| _run_analysis |
---|
| _run_analysis |
---|
nopanel | true |
---|
| then click YES to confirm. - When PhixFlow notifies you that the analysis is finished, hover your mouse pointer over the stream again.
- Click
Insert excerpt |
---|
| _stream_views |
---|
| _stream_views |
---|
nopanel | true |
---|
| . - In the drop-down list, select
Insert excerpt |
---|
| _view_default |
---|
| _view_default |
---|
nopanel | true |
---|
| . PhixFlow displays the data.
|
Snapshot of your model and the data you have loaded:
...
- Hover your mouse pointer over the
Latest Package Update
stream and click Insert excerpt |
---|
| _stream_add |
---|
| _stream_add |
---|
nopanel | true |
---|
|
. - In Basic Settings, set the Name to
Latest Package All Channels
. Drag all the attributes from Latest Package Update
to the settings property tab for Latest Package All Channels
.
Expand |
---|
|
- Hover your mouse pointer over the stream
Latest Package Update . - In the context toolbar, click
Insert excerpt |
---|
| _stream_attributes |
---|
| _stream_attributes |
---|
nopanel | true |
---|
| . Phixflow lists the data attributes (column titles) for this stream. - Select all the attributes and drag them into the
Latest Package All Channels settings → Channels property tab → Attributes section.
|
- Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save and close the settings property tab. - Close the attributes list.
...
- In the model, add a pipe from
SOURCE_PACKAGE_CHANNELS
to Latest Package All Channels
. PhixFlow opens the settings property tab for the new pipe. - In the Basic Settings section, set:
- Name:
find_channels
- Type: Look-up
- In the Order/Index section, click
Insert excerpt |
---|
| _stream_attributes |
---|
| _stream_attributes |
---|
nopanel | true |
---|
|
. PhixFlow opens two lists of attributes: one list for the source stream and another for the receiving stream. - From the source stream list, on the left, drag
PACKAGE
into the Order/Index grid.
This tells PhixFlow about the key column in the source stream. Notice that PhixFlow has added a line to the Order/Index grid. - From the receiving stream list, on the right, drag
Package
over the top of the line in the Order/Index grid.
This tells PhixFlow about the matching key column in the receiving stream. Notice that PhixFlow has now added the Index Expression _outPackage
. However, we do not want PhixFlow to use _outPackage
. because output multipliers are calculated before the output is generated. We need it to use the data on the input.
This means that the lookup will match records in the reference data (SOURCE_PACKAGE_CHANNELS
) where PACKAGE
= Package
is from the input pipe in.
We must do this, rather than using the value of Package
from the output, because we are GOING TO USE the lookup to drive an output multiplier – and output multipliers are calculated before the output is generated.
- In the Order/Index section, double-click the new line that PhixFlow has added. PhixFlow opens the settings property tab for the
PACKAGE
attribute. Set:- Basic Settings → Index Expression from
_out.Package
to in.Package
. - Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save and close the settings property tab.
- Close the attribute list.
- In the pipe settings property tab, click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save and close the settings tab. - In the model toolbar, click to save your model, which should look like this:
At this point, if you run your model it will find each customer, e.g. C010, and will read that the customer has the News
package. It will then look-up the channel for this to find News: Channel 1. But having done one look-up for the customer it will move onto the next customer.
...
An output multiplier tells PhixFlow to process the same record multiple times, each time producing a new record. This is called breaking-out a record. In this case we want PhixFlow to keep processing the same customer record until it has found all the channels. This means our single input record:
becomes multiple output records, like this:
C010 | News | Channel 1 |
C010 | News | Channel 2 |
C010 | News | Channel 3 |
C010 | News | NewsExtra |
The output multiplier needs to know:
...
- In the model, double-click
Latest Package All Channels
to open its settings property tab. - To create the output multiplier, expand the Multipliers and Filters section and set:
- Output Multiplier:
find_channels.CHANNEL
- To create a new column for the channel data, expand the Attributes section. Click to add a new attribute. PhixFlow opens a new attribute settings property tab. Set:
- Name:
Channel
- Expression:
_outputMultiplier
- Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save and close the settings property tab. - In the model toolbar, click to save your model.
Run the model and view the stream data.
Expand |
---|
|
- Hover your mouse pointer over the
Latest Package All Channels stream and click Insert excerpt |
---|
| _run_analysis |
---|
| _run_analysis |
---|
nopanel | true |
---|
| then click YES to confirm. - When PhixFlow notifies you that the analysis is finished, hover your mouse pointer over the
Latest Package All Channels stream again. - Click
Insert excerpt |
---|
| _stream_views |
---|
| _stream_views |
---|
nopanel | true |
---|
| . - In the drop-down list, select
Insert excerpt |
---|
| _view_default |
---|
| _view_default |
---|
nopanel | true |
---|
| . PhixFlow displays the data.
|
There should be 33 records. Here is a snapshot of the start of the data:
Notice that there are now multiple records for each customer.
...