Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
...
...
...
...
...
...
...
Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
By the end of this chapter you will be able to:
- Merge directly from database collectors
...
- Populate attributes with key values using the '_key[n]' notation
In this exercise you will repeat the comparison you did in the previous exercise, of the full channel list in your model against the list in the inventory database – but this time using a
...
merge:
- Add a new
...
- merge table to your
Channel Package Check
model, by dragging
...
- in
from the analysis toolbar.Insert excerpt _table_merge _table_merge nopanel true - Name this table:
Channel List Reconciliation 2
- Add
...
- a pipe from
Latest Package All Channels
, with the Name:sales
- Drag the following attributes from
Latest Package All Channels
toChannel List Reconciliation 2
:CustomerRef
Channel
- Add
...
- a pipe from the
...
- database collector
SOURCE_ALL_CHANNELS_LIST
toChannel List Reconciliation 2
...
Name this pipe
...
If you set up a merge directly from an external database table you cannot use PhixFlow's automated merge builder – therefore, if possible, always load data from external tables into PhixFlow first, and then merge |
:
inv
Set up the grouping attributes on the
...
pipe:
- Double click on the pipe
sales
- Go to the Sort/Group
- Double click on the pipe
...
- section.
- Press
and drag in the attributesInsert excerpt _attributes_show _attributes_show nopanel true CustomerRef
andChannel.
- Press
...
to save your changes.Insert excerpt _finish _finish nopanel true
- Double-click on the pipe
inv
- Go to the Sort/Group
...
- section.
- Press
...
.Insert excerpt _addIcon _addIcon nopanel true - In the new
...
- grouping attribute form that pops up:
- Select the attribute
CustomerRef
from the drop down list. - Tick the Group flag
- Press
- Select the attribute
- grouping attribute form that pops up:
...
.Insert excerpt _finish _finish nopanel true
- Add the grouping attribute
Channel
in the same way. - Back in the
...
- pipe
...
- Properties, press
...
.Insert excerpt _finish _finish nopanel true
Now you will complete the configuration of the
...
merge table, using the _key internal variable to write key values into the
...
table:
- Double
...
- click on
Channel List Reconciliation 2
to open the
...
- Properties.
- Double
...
- click the
...
- attribute
CustomerRef.
- In the
...
- attribute details form that pops up, update Expression to:
_key[1]
- This writes the first key value into this attribute
- attribute details form that pops up, update Expression to:
...
- .
- Press
Insert excerpt _finish _finish nopanel true - Double click the attribute
Channel
- In the
...
- attribute details form that pops up, update Expression to:
_key[2]
- This writes the second key value into this attribute.
- Press
- attribute details form that pops up, update Expression to:
...
.Insert excerpt _finish _finish nopanel true - Add an
...
- attribute
SalesCheck
, and set the Expression to
- attribute
Code Block |
---|
if (countElements(sales) == 1, |
...
"YES" |
...
, |
...
"NO" |
...
) |
...
3. Add an attribute InvCheck
, and set the Expression to:
Code Block |
---|
if (countElements(inv) == 1, |
...
"YES" |
...
, |
...
"NO" |
...
) |
...
4. Press
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
5. Update
...
the Expression in the
...
SOURCE_ALL_CHANNELS_LIST database collector to:
Code Block |
---|
select * from SOURCE_ALL_CHANNELS_LIST |
...
order by CustomerRef, Channel |
...
6. Toggle
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
The ordering (order by) is needed to support the merge |
...
. When merging directly from database tables |
...
, you have to repeat the ordering of data across the query and the pipe; that is, the ordering of data in the |
...
database collector query |
...
must match the grouping on the pipe from the |
...
database collector. |
6. Run Analysis on Channel List Reconciliation 2.
7. In your results you should see an additional 3 records that were not included in the reconciliation you did in the previous exercise – channels that are recorded in the inventory, but not in the channels list, are included in your output.
This is because a
...
merge will generate an output record for every key value it finds across all input pipes, whereas if you do a data enrichment using a lookup pipe – you will only get an output record for every record from the input pipe
...
.
Filter unmatched rows
To help you find unmatched rows in your output data, you will now add a filter
...
:
- Open the
...
- recordset you have just generated in
Channel List Reconciliation 2
...
- by hovering over this table and pressing
Insert excerpt _recordsets_show _recordsets_show nopanel true .
- Create a filter:
- Where ANY of the following are true
- Where ANY of the following are true
...
SalesCheck
...
- equals
...
NO
...
InvCheck
...
- equals
...
NO
...
- Press Apply to apply the filter without saving.
- You will get a list of all non-matched records, that is, all records where the
SalesCheck
value isNO
or theInvCheck
value isNO.
- In the model window, click
.Insert excerpt _save_saveModel _save_saveModel nopanel true