...
- 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
Anchor |
---|
| _Toc442889065 |
---|
| _Toc442889065 |
---|
|
Reformat post codes to remove all spaces and make upper caseYou will reformat post codes to remove all spaces, and ensure that all letters are upper case:
- In your model, add a new Stream:
- Hover over Customer Details with Region, and press press Image Modified - Add a new Stream
- Give the new Stream the Name: Reformatted Customer Details
- Drag all Attributes from Customer Details with Region to the new Stream
- 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 a new attribute:
- Press 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
toUpper(replaceAll(in.in_PostCode, " ", ""))
- Press Image Modified
In the left-hand menu bar press - 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.
Anchor |
---|
| _Toc442889066 |
---|
| _Toc442889066 |
---|
|
Generate short code for CountiesNow 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 the attribute expression with
substring(
- Press Press Image Modified - 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 Press Image Modified
Anchor |
---|
| _Toc442889067 |
---|
| _Toc442889067 |
---|
|
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 with: if (
- Press Image Removed Press Image Added - 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: > 10.0, "LARGE", "NORMAL")
- Your attribute expression should now say: if (_out.BILLAMOUNT > 10.0, "LARGE", "NORMAL")
- Press Image RemovedPress Image Added
Anchor |
---|
| _Toc442889068 |
---|
| _Toc442889068 |
---|
|
Set special processing flagFinally, you will now set a special processing flag – this will be set to "Yes" when the last bill for the customer is large. To do this, we need to access an attribute value in the Stream, but which is not in any of the input pipes to the Stream - only in the 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: if (
- Press Image Removed Press Image Added - Show Inputs
- In the list of Inputs (the top window) select This
- Drag the attribute BillCategory from the list of attributes into the attribute expression
- This will add _out.BillCategory to your attribute expression
- Complete the attribute expression with: == "LARGE", "YES", "NO")
- Your attribute expression should now say: if (_out.BillCategory == "LARGE", "YES", "NO")
- Press Image RemovedPress Image Added
Anchor |
---|
| _Toc442889069 |
---|
| _Toc442889069 |
---|
|
Run stream- In the main stream configuration form, press Image Removedpress Image Added
- Remember to save your model layout.
- Run Analysis on Reformatted Customer Details
- Have a look at the data in the new Stream – check that all your transformations have been correctly applied