Versions Compared

Key

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

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

...

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 browser, expand the list of Datasources.
  2. Drag the datasource called Rating and Billing into your model.
  3. In your model, hover your mouse pointer over Rating and Billing and click 
    Insert excerpt
    _table_tablesdatabase
    _tablestable_database
    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
    _createcollector_collectornew
    _createcollector_collectornew
    nopaneltrue
    . 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 property tab → Basic Settings section → Statement Expression, you can see the database query is: 
      select * from SOURCE_PACKAGE_CHANNELS.
  5. Hover your mouse pointer over the new database collector, and click 
    Insert excerpt
    _streamtable_with_attributes
    _streamtable_with_attributes
    nopaneltrue
    . PhixFlow adds a new stream to your model and also gives it the name SOURCE_PACKAGE_CHANNELS. In the property tab Attributes section, you can see that the data has two attributes (columns): Package and Channel.
  6. To load the data into the stream, 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 stream , 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 stream again.
    3. Click 
      Insert excerpt
      _streamview_viewsshow
      _streamview_viewsshow
      nopaneltrue
      .
    4. In the drop-down list, select 
      Insert excerpt
      _view_default
      _view_default
      nopaneltrue
      .  PhixFlow displays the data.

    Snapshot of your model and the data you have loaded:

...

  1. Hover your mouse pointer over the Latest Package Update stream and click 
    Insert excerpt
    _streamtable_addnew
    _streamtable_addnew
    nopaneltrue
    .
  2. In Basic Settings, set the Name to Latest Package All Channels.
  3. Drag all the attributes from Latest Package Update to the property tab for Latest Package All Channels.

    Expand
    titleHow?
    1. Hover your mouse pointer over the stream Latest Package Update.
    2. In the context toolbar, click 
      Insert excerpt
      _stream_attributes_stream
      _attributes
      nopaneltrue
      . Phixflow lists the data attributes (column titles) for this stream.
    3. Select all the attributes and drag them into the Latest Package All Channels  property tab Attributes section.


  4. Click 
    Insert excerpt
    _finish
    _finish
    nopaneltrue
     to save and close the property tab.
  5. Close the attributes list.

...

  1. In the model, add a pipe from SOURCE_PACKAGE_CHANNELS to Latest Package All Channels. PhixFlow opens the property tab for the new pipe.
  2. In the Basic Settings section, set:
    • Name: find_channels
    • Type: Look-up
  3. In the Order/Index section, click 
    Insert excerpt
    _stream_attributes
    _stream_attributes
    nopaneltrue
    . PhixFlow opens two lists of attributes: one list for the source stream and another for the receiving stream. 
  4. 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.
  5. 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 (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.

  6. In the Order/Index section, double-click the new line that PhixFlow has added. PhixFlow opens the property tab for the PACKAGE attribute. Set:
    •  Basic Settings → Index Expression from _out.Package to in.Package.
    • Click 
      Insert excerpt
      _finish
      _finish
      nopaneltrue
       to save and close the property tab.
  7. Close the attribute list.
  8. In the pipe property tab, click 
    Insert excerpt
    _finish
    _finish
    nopaneltrue
     to save and close.
  9. In the model toolbar, click 
    Insert excerpt
    _save
    _save
    nopaneltrue
     to save your model, which should look like this:

...

  1. In the model, double-click Latest Package All Channels to open its property tab.
  2. To create the output multiplier, expand the Multipliers and Filters 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
    _addnew
    _addnew
    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
     to save and close the property tab.
  5. In the model toolbar, click 
    Insert excerpt
    _save
    _save
    nopaneltrue
     to save your model.
  6. Run the model and view the stream data.

    Expand
    titleHow?
    1. Hover your mouse pointer over the Latest Package All Channels stream 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 stream again.
    3. Click 
      Insert excerpt
      _streamview_viewsshow
      _streamview_viewsshow
      nopaneltrue
      .
    4. In the drop-down list, select 
      Insert excerpt
      _view_default
      _view_default
      nopaneltrue
      .  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.

...