By the end of this chapter you will be able to:
So far your model has merged data from two files, then grouped and sorted the records. You now have a table that has the latest data about the TV Package that each Customer has.
You now want all the channels that the customer has ordered. You will look up the data about the channels provided by each package from a database table. To make sure that PhixFlow finds all the channels, you will use an output multiplier.
First, load the database table SOURCE_PACKAGE_CHANNELS
into a table as described below. Your model will then have the list of channels available in each package:
Remember, the Introduction to Modelling course explains about loading data from databases; see section 3 Creating Datasources and Database Collectors. |
Rating and Billing
into your model.Rating and Billing
and click SOURCE_PACKAGE_CHANNELS
and select SOURCE_PACKAGE_CHANNELS
. In the Properties (on the right) → Basic Settings section → Statement Expression, you can see the database query is: select * from SOURCE_PACKAGE_CHANNELS
.SOURCE_PACKAGE_CHANNELS
database collector, and click SOURCE_PACKAGE_CHANNELS
. In the Properties → Attributes section, you can see that the data has two attributes (columns): Package and Channel.To load the data into the table, run analysis on this section of the model and check the data has loaded.
|
Screenshot of your model and the data you have loaded:
Take a moment to look at this data. For each package, there are multiple channels included. For example, the News package includes Channel 1, Channel 2, Science 2 and NewsExtra.
Update your model to add a table. This table will take all the data that we have merged, sorted and grouped in the model so far:
Latest Package Update
table and click Latest Package All Channels
.Drag all the from
Latest Package Update
to the property tab for Latest Package All Channels
.
|
You now need to add to the data in the Latest Package All Channels
table. You will use a look-up pipe to add the channels provided by a package. PhixFlow needs to know how the data in the source table matches the data in the receiving table.
SOURCE_PACKAGE_CHANNELS
to Latest Package All Channels
. PhixFlow opens the Properties for the new pipe.find_channels
PACKAGE
into the Order/Index grid.Package
over the top of the line in the Order/Index grid._out.Package
. However, we do not want PhixFlow to use _out.Package
because output multipliers are calculated before the output values is generated (see PhixFlow Timing Cycle). We need it to use the data 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.PACKAGE
attribute. Set:_out.Package
to in.Package
.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.
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:
C010 | News |
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:
find_channels
.The table also needs to create the new column for the channel information.
Latest Package All Channels
to open its Properties.find_channels.CHANNEL
Channel
_outputMultiplier
|
There should be 33 records, similar to the below image:
Notice that there are now multiple records for each customer. In the model toolbar, click to save your model.