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:
- 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
...
- table:
- Hover over
Customer Details with Region
, and press
- Hover over
...
.Insert excerpt _table_new _table_new nopanel true - Give the new
...
- table the Name:
Reformatted Customer Details
- Drag all attributes from
Customer Details with Region
to the new
- table the Name:
...
- table.
- Open the configuration form for
Reformatted Customer Details
- In the Attributes section, add a new attribute:
- Press
- In the Attributes section, add a new attribute:
...
Insert excerpt _add _add nopanel true - 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 Removed
...
- Press
.Insert excerpt _finish _finish nopanel true
- Press
Above the Attribute Expression the help link will open a page containing details of all attribute functions available in PhixFlow
...
. Find the attribute functions you used above – toUpper() and replaceAll()
...
– click each of these to see the help pages specifically for these functions.
Inline help is also provided for functions, this will appear as you type. At the bottom of the popup help is a link directly to the page for the function in question.
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.
Set the attribute expression to:
Code Block substring(in.County, 1, 3)
Press
...
.Insert excerpt _finish _finish nopanel true
Categorise bills as "LARGE" or "NORMAL"
Categorise bills as "LARGE" or "NORMAL":
- Add a new attribute called
BillCategory
- Leave the default settings.
...
Set the attribute expression to:
Code Block if (in.BILLAMOUNT > 10.0, "LARGE", "NORMAL")
Press
...
.Insert excerpt _finish _finish nopanel true
Set special processing flag _out
Finally, 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
...
table, but which is not in any of the input pipes to the
...
table - only in the
...
table output. To do this, you will use the internal variable _out:
- Add a new attribute called
SpecialProcessing
- Leave the default settings.
...
set the attribute expression
...
to:
Code Block if (_out.BillCategory == "LARGE", "YES", "NO")
Press
...
.Insert excerpt _finish _finish nopanel true
Run
...
table
- In the main
...
- table configuration form, press
...
.Insert excerpt _finish _finish nopanel true - Remember to save your model layout,
.Insert excerpt _save _save nopanel true - Run analysis on
Reformatted Customer Details
- Have a look at the data in the new
...
- table – check that all your transformations have been correctly applied.