Versions Compared

Key

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

...

  • Use the attribute function replaceAll()
  • Use the attribute function toUpper()
  • Use the attribute function substring()
  • Use the attribute function if()
  • Use the internal variable _out

...

Reformat post codes to remove all spaces and make upper case

You will reformat post codes to remove all spaces, and ensure that all letters are upper case:

  1. In your model, add a new

...

  1. stream:
    1. Hover over Customer Details with Region, and

...

    1. press Image Modified

...

    1. Add a new Stream
    2. Give the new Stream the Name: Reformatted Customer Details
    3. Drag all

...

    1. attributes from Customer Details with Region to the new

...

    1. stream
  1. Open the configuration form for Reformatted Customer Details

...


    1. In the Attributes section, add a new attribute:

    ...

        • Press Image Modified
        • In the attribute details form that pops up:
        • Set the Name: ReformattedPostCode
        • Leave the settings for the attribute as default (Type is String, Length is 50)
        • Set the Attribute Expression to
    Code Block
    toUpper(replaceAll(in.

    ...

    PostCode, " ", ""))
      • Press Image Modified

    In the left-hand menu bar press Image Removed - Show the List of Attribute repository browser find Image Added Attribute Functions. All attribute functions available in PhixFlow are shown. Find the attribute functions you used above – toUpper() and replaceAll() – and double-click each of these to see the help pages for these functions.

    ...

    Generate short code for Counties

    Now you will generate a short code for counties by taking the first 3 letters of the county for each customer detail record:

    1. Add a new attribute called CountyShortCode
    2. Leave the default settings

    ...

    substring(

    • Press Image Removed - Show Inputs
    • In the list of Inputs (the top window) select This
    • The list of Attributes (the bottom window) will update to the list of attributes available from the stream you are building. The other input, in, will give you the list of attributes in the stream that is linked to this stream by the pipe in
    • Drag the attribute in_County from the list of input attributes into your attribute expression
    • You will see that this adds _out.in_County to the attribute expression
    • Complete the attribute expression with: , 1, 3)
    • Your attribute expression should now say: substring(_out.in_County, 1, 3)
    • Press Image Removed

    ...

    1. Set the attribute expression to

      Code Block
      substring(in.County, 1, 3)


    2. Press Image Added

    Categorise bills as "LARGE" or "NORMAL"

    Categorise bills as "LARGE" or "NORMAL":

    1. Add a new attribute called BillCategory
    2. Leave the default settings
    3. Start the

    ...

    1. attribute expression

    ...

    1. to:

      Code Block
      if (in.BILLAMOUNT > 10.0, "LARGE", "NORMAL")

    ...


    1. Press Image Added

    Set special processing flag

    Finally, you will now set a special processing flag – this will be set to "YesYES" when the last bill for the customer is large. To do this, we need to access an attribute value in the Streamstream, but which is not in any of the input pipes to the Stream stream - only in the Stream stream output. To do this, you will use the internal variable _out:

    1. Add a new attribute called SpecialProcessing
    2. Leave the default settings
    3. Start the attribute expression with:

    ...

    1. Code Block
      if (_out.BillCategory == "LARGE", "YES", "NO")

    ...


    1. Press Image Added

    Run stream

    1. In the main stream configuration form,

    ...

    1. press Image Added
    2. Remember to save your model layout.
    3. Run

    ...

    1. analysis on Reformatted Customer Details
    2. Have a look at the data in the new

    ...

    1. stream – check that all your transformations have been correctly applied