You will also learn how to use an internal variable, _pipeName.
In this exercise you will produce a single list of updates to customers' Cable TV packages. Customers can update their packages both through a customer care system and in shops. You will bring all these updates together into a single list.
Read in data sets from files
For this exercise you need two files from the zip file you downloaded in 2 Using Excel Templates, step 5. The files contain updates from the two sources: the customer care system and the shop.
Screenshot of the Channel Package Check model so far:
Combine the data sets
Create a new stream in your model and populate its attributes.
Hover over CustomerCareUpdates and click Create New Table
In the settings, set the Name to Combined Updates.
In the model, show the stream attributes for CustomerCareUpdates .
Select all the attributes and drag them into the properties for the Combined Updates stream. Drop them into the Attributes section.
Click OK.
To save your model, in the model toolbar click Save.
Connect the ShopUpdates stream to the Combined Updates stream.
Hover over ShopUpdates and click Connector.
Click Combined Updates to link the pipe to the stream.
When you connect streams, PhixFlow automatically adds a reference to the input pipe name. This appears in the attribute expression. To merge this data successfully, you must update the attribute expressions to remove the in. prefix; see step 4 below.
Fix all the attribute expressions.
Double-click on Combined Updates to open its settings tab. For each attribute:
In the Attributes section, double-click on an attribute to open its settings.
In the Basic Settings section, edit the Expression to remove in. and click OK
In the Combined Updates stream settings tab, click OK to save and close.
In the model, hover your mouse pointer over Combined Updates and click Run Analysis.
When the stream has run, check that the stream has:
the columns CustomerRef, Sales Date and Package
15 rows
all cells have data. The stream default view:
Snapshot of the Chanel Package Check model so far:
Record the source for each update
You will now update your settings to record the source for each update, in the set of combined updates. To do this:
To update the name of the pipe from the CustomerCareUpdates stream to the Combined Updates stream:
In the model, click on the pipe to open its settings tab.
Set Name to CC.
Click OK to save and close the pipe settings.
Update the name of the pipe from the ShopUpdates file collector to the ShopUpdates stream.
In the model, click on the pipe to open its settings tab.
Set Name to shop
Click OK to save and close pipe settings.
Double-click the stream Combined Updates to open its settings tab.
In the Attributes section, click Create New add a new attribute and set:
Name: Source.
Expression:
if (_pipeName == "CC",
"Customer Care"
,
"Shop"
)
Click OK to save and close the attribute settings.
To make Source the first attribute in the stream, drag it to the top of the attributes list.
Click OK to save and close the stream settings.
Run analysis on Combined Updates.
Check the output data set and make sure that the source has been recorded on each record correctly.