Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: DOC-73 Revise page

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

Table of Contents

You will also learn how to limit a pipe to read a maximum number of data records.

In this exercise you will select the latest (most recent) sales record for each customer, from the set of combined updates you created in the previous exercise.

...

When you next run this model, the Latest Package Updates stream will pull in the all the data from the Combined Updates stream.

...

  • Group the data, so that all the records with the same Customer Ref number are adjacent in the table.
  • Sort the data by date, newest to oldest, using Sales Date. This means that the first record delivered by the input pipe, for each Customer Ref, is the most recent for that customer.
  1. Double click on the pipe from the  Combined UpdatesGo to the stream.
  2. Expand the Sort/Group section toolbar.
  3. In the section Press toolbar, click
    Insert excerpt
    _stream_attributes
    _stream_attributes
    nopaneltrue
     (check Image Modified - Show Stream Attributes)?? Phixflow opens a list of the attributes - how does it know these?
  4. Drag in CustomerRef. By default, it is set to have Group ticked and Direction A-Z
  5. Drag in SalesDate
  6. You will leave CustomerRef as a grouping attribute
  7. You will update SalesDate to be a ordering attribute. To make this an ordering attribute:
    1. Double-click on SalesDate in the Sort/Group attributes list grid
    2. Set the Sort Direction to descending: Z-A
    3. Untick the Group flagPress Image Removed.
    4. Click 
      Insert excerpt
      _finish
      _finish
      nopaneltrue
       to save the change and close the attribute settings.
  8. Set Maximum Number of Records per Group to
  9. : 1
  10. 1.
  11. Click 
    Insert excerpt
    _finish
    _finish
    nopaneltrue
     to save and close the pipe settings.
    Image Added

This setting means that for each key value – in this case for each value of CustomerRef – only the first record will be returned; since you have also ordered by SalesDate descending, this will be the latest (most recent) record for each CustomerRef

...

This is effectively filtering out old records for the same customer.

Test your new Stream

  • Run analysis on your new stream
  • Make sure that for all customers the most recent sales update has been selected