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:

  • In your model, add a new Streamstream:
    • Hover over Customer Details with Region, and press  - Add a new Stream
    • Give the new Stream the Name: Reformatted Customer Details
    • Drag all Attributes attributes from Customer Details with Region to the new Streamstream
  • Open the configuration form for Reformatted Customer Details – double click on the Stream icon on the model pane
  • The configuration form will open on the Attributes tab
  • Add
    • In the Attributes section, add a new attribute:
      • Press 
      • 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.in_PostCode, " ", ""))
    • Press

In the left-hand menu bar press repository browser find - Show the List of 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:

  • Add a new attribute called CountyShortCode
  • Leave the default settings
  • Start Set the attribute expression withto
Code Block
substring(

...

(

...

in

...

.

...

County

...

Code Block
 , 1, 3)
  • Your attribute expression should now say: substring(_out.in_County, 1, 3)
  • Press 

...

...

Categorise bills as "LARGE" or "NORMAL"

Categorise bills as "LARGE" or "NORMAL":

  • Add a new attribute called BillCategory
  • Leave the default settings
  • Start the Attribute Expression withattribute expression to:
Code Block
if (
  • Press Image Removed - Show Inputs
  • In the list of Inputs (the top window) select This
  • Drag the attribute BILLAMOUNT from the list of attributes into the attribute expression
  • This will add _out.BILLAMOUNT to your attribute expression
  • Complete the attribute expression with:
Code Block
in.BILLAMOUNT > 10.0, "LARGE", "NORMAL")

...

"

...

NORMAL")
  • Press 

...

...

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:

  • Add a new attribute called SpecialProcessing
  • Leave the default settings
  • Start the attribute expression with:
Code Block
if (

...

_out.BillCategory

...

Code Block
 == "LARGE", "YES", "NO")

...

"

...

NO")
  • Press 

...

Run stream

  • In the main stream configuration form, press 
  • Remember to save your model layout.
  • Run Analysis analysis on Reformatted Customer Details
  • Have a look at the data in the new Stream stream – check that all your transformations have been correctly applied