Versions Compared

Key

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

Insert excerpt
_Banners
_Banners
nameanalysis
nopaneltrue

By the end of this chapter you will be able to:

Table of Contents

Use an output multiplier to break out a record into multiple output records

...

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.

Load data from a database table

...

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

...

:

Tip

Remember, the Introduction to Modelling course explains about loading data from databases; see section 3 Creating Datasources and Database Collectors.


  1. In the repository

...

  1. , expand the list of Datasources.
  2. Drag the datasource called Rating and Billing into your model.
    1. In the Properties (on the right), in the Datasource Instances section, double-click Default
    2. Update the fields URL, Username and Password with those provided in your training email.
    3. Save your changes.
  3. In your model, hover your mouse pointer over Rating and Billing and click 
    Insert excerpt
    _datasource_show_tables
    _datasource_show_tables
    nopaneltrue
    . PhixFlow displays a list of the tables available in this database. You can resize the list to make it easier to browse.
  4. Right-click on SOURCE_PACKAGE_CHANNELS and select 
    Insert excerpt
    _

...

  1. collector_

...

  1. new
    _

...

  1. collector_

...

  1. new
    nopaneltrue
    . PhixFlow adds a new

...

  1. Insert excerpt
    _database_collector
    _database_collector
    nopaneltrue
     to the model, and gives it the same name as the source data table, SOURCE_PACKAGE_CHANNELS. In the

...

  1. Properties (on the right) → Basic Settings section → Statement Expression, you can see the database query is: 
      select * from SOURCE_PACKAGE_CHANNELS.
  2. Hover your mouse pointer over the

...

  1. new SOURCE_PACKAGE_CHANNELS database collector, and click 
    Insert excerpt
    _

...

  1. table_with_

...

  1. attributes
    _

...

  1. table_with_

...

  1. attributes
    nopaneltrue

...

  1. . PhixFlow adds a new

...

  1. table to your model and also gives it the name SOURCE_PACKAGE_CHANNELS. In the

...

  1. Properties Attributes section, you can see that the data has two attributes (columns): Package and Channel.
  2. To load the data into the

...

  1. table, run analysis on this section of the model and check the data has loaded.

    Expand
    titleHow?

...

    1. Hover your mouse pointer over the SOURCE_PACKAGE_CHANNELS

...

    1.  table, click 
      Insert excerpt
      _run_analysis
      _run_analysis
      nopaneltrue
       then click YES to confirm.
    2. When PhixFlow notifies you that the analysis is finished, hover your mouse pointer over the

...

    1. table again.
    2. Click 
      Insert excerpt
      _view_show
      _

...

    1. view_

...

    1. show

...

    1. nopaneltrue
      .
    2. In the drop-down list, select 
      Insert excerpt
      _view_default
      _view

...

    1. _default

...

    1. nopaneltrue
      .  PhixFlow displays the data.

...

  1. Screenshot of your model and the data you have loaded:

...


  1. Image Added

...

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.

Add another table 

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:

  1. Hover your mouse pointer over the Latest Package Update

...

  1. table and click 
    Insert excerpt
    _

...

  1. table_

...

  1. new
    _

...

  1. table_

...

  1. new
    nopaneltrue

...

  1. .
  2. In Basic Settings, set the Name to Latest Package All Channels.
  3. Drag all the

...

  1. Insert excerpt
    _attributes
    _attributes
    nopaneltrue
     from Latest Package Update to the

...

  1. property tab for Latest Package All Channels.

    Expand
    titleHow?
    1. Hover your mouse pointer over the

...

    1. table Latest Package Update.
    2. In the context toolbar, click 
      Insert excerpt

...

    1. _attributes

...

    1. _attributes
      nopaneltrue
      . Phixflow lists the data attributes (column titles) for this

...

    1. table.
    2. Select all the attributes and drag them into the Latest Package All

...

    1. Channels  property tab Attributes section.


  1. Click 
    Insert excerpt
    _finish
    _finish
    nopaneltrue
     to save

...

  1. and close the

...

  1. Properties.
  2. Close the attributes list.

...

Supplement the table with look-up data

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.

  1. In the model, add a pipe from SOURCE_PACKAGE_CHANNELS

...

  1.  to Latest Package All Channels

...

  1. . PhixFlow opens the Properties for the new pipe.
  2. In the Basic Settings section, set:
    • Namefind_channels
    • Type: Look-up
  3. Click 
    Insert excerpt
    _save
    _save
    nopaneltrue
     to register the change of pipe.
  4. In the Order/Index section, click 

    ...

    Insert excerpt
    _attributes
    _attributes
    nopaneltrue
    . PhixFlow opens two lists of attributes: one list for the source table and another for the receiving table. 
    1. From the source table list, on the left, drag PACKAGE into the Order/Index grid.
      Image Added
    2. This tells PhixFlow about the key column in the source table. Notice that PhixFlow has added a line to the Order/Index grid.
  5. From the receiving table list, on the right, drag Package over the top of the line in the Order/Index grid.
    1. Image Added

    This tells PhixFlow about the matching key column in the receiving table. Notice that PhixFlow has now added the Index Expression _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

...

  1. going to use the lookup to drive an output multiplier – and output multipliers are calculated before the output is generated

...

  • Open the configuration form for the stream Latest Package All Channels by double clicking it
  • In the field Output Multiplier, enter the value: chan.CHANNEL

This means that for each output record processed, PhixFlow will look up the list of channels for the package from the reference stream; it will then work through the list returned, handling each element from the list in turn and generating an output record in the stream for each one

  • Add an attribute to the stream with Name Channel
  • Set the Expression of this attribute to _outputMultiplier

This will print the value of the current element of the output multiplier list to this field

...

On older models in PhixFlow you may see the internal variable _type. This is the old name for _outputMultiplier. Either can be used, and anywhere you see _type you can update it to _outputMultiplier for clarity.

...

  1. .
  2. In the Order/Index section, double-click the new line that PhixFlow has added. PhixFlow opens the property tab for the PACKAGE attribute. Set:
    • In the Basic Settings → Index Expression change from _out.Package to in.Package.
    • Click 
      Insert excerpt
      _finish
      _finish
      nopaneltrue
       to save and close the property tab.
  3. Close the attribute list.
  4. In the pipe property tab, click 
    Insert excerpt
    _finish
    _finish
    nopaneltrue
     to save and close.
  5. In the model toolbar, click 
    Insert excerpt
    _save_saveModel
    _save_saveModel
    nopaneltrue
     to save your model, which should look like this:
    Image Added

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.

Set an output multiplier

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:

C010News

becomes multiple output records, like this:

C010NewsChannel 1
C010NewsChannel 2
C010NewsChannel 3
C010NewsNewsExtra

The output multiplier needs to know:

  • which pipe it will use -  find_channels.
  • what data you want to add - the channels.

The table also needs to create the new column for the channel information.

  1. In the model, double-click Latest Package All Channels to open its Properties.
  2. To create the output multiplier, expand the Analysis Options section and set:
    • Output Multiplier: find_channels.CHANNEL
  3. To create a new column for the channel data, expand the Attributes section. Click 
    Insert excerpt
    _new
    _new
    nopaneltrue
     to add a new attribute. PhixFlow opens a new attribute property tab. Set:
    •  Name: Channel
    •  Expression: _outputMultiplier
  4. Click 
    Insert excerpt
    _finish
    _finish
    nopaneltrue
     on both the New Table Attribute Properties and the Latest Package All Channels Properties.
  5. Run the model and view the table data.
Expand
titleHow?
  1. Hover your mouse pointer over the Latest Package All Channels table and click 
    Insert excerpt
    _run_analysis
    _run_analysis
    nopaneltrue
     then click YES to confirm.
  2. When PhixFlow notifies you that the analysis is finished, hover your mouse pointer over the Latest Package All Channels table again.
  3. Click 
    Insert excerpt
    _view_show
    _view_show
    nopaneltrue
    .
  4. In the drop-down list, select 
    Insert excerpt
    _view_default
    _view_default
    nopaneltrue
    .  PhixFlow displays the data.
  5. Select 
    Insert excerpt
    _more_options
    _more_options
    nopaneltrue
     on the View and 
    Insert excerpt
    _paging
    _paging
    nopaneltrue
     to show the number of records.

There should be 33 records, similar to the below image:

Image Added

Notice that there are now multiple records for each customer. In the model toolbar, click 

Insert excerpt
_save_saveModel
_save_saveModel
nopaneltrue
 to save your model.