Versions Compared

Key

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

...

Insert excerpt
_Banners
_Banners
nameanalysis
nopaneltrue

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

  • Use the switch() function
  • Use the forEach() function

...


Additional assistance can be found in Expression Basics.

Using switch() to apply multiple tests

  1. Create a new model

...

  1. Attribute Scripting
  2. Drag the datasource CRM onto this model.
  3. From the datasource

...

  1. hover menu use the
    Insert excerpt
    _tableOnly
    _tableOnly
    nopaneltrue
     option to display all available tables.
  2. Find the table SOURCE_BANK_ACCOUNT_TRANS, right-click and select create a

...

  1. collector

...

  1. .
  2. Create a

...

  1. table from this database collector

...

  1. , remember to use the 

...

  1. Insert excerpt
    _table_new
    _table_new
    nopaneltrue
     button in the hover menu so that the

...

  1. table attributes are automatically configured

...

  • Press the button Image Removed in the left-hand menu bar of PhixFlow – a list of all attribute functions available in PhixFlow will appear
  • Double-click on the entry for switch to bring up the help page
  1. .
  2. Add an attribute to this

...

  1. table to hold a description of the transaction type:
    1. Name: TransactionTypeDesc
    2. Expression: work out the transaction type description from TRANSACTION_TYPE, using a switch() statement, according to the rules below – Search the help and use the examples in the help for switch() to get started

...

TRANSACTION_TYPE

Description

1

"Direct Debit"

2

"Standing Order"

3

"ePayment"

4

"Cheque"

Any other value

"Unknown"

...

  • Create an aggregate stream, with name Bank Account Summary
  • Add a pipe from the stream you created in the previous exercise (this is probably called SOURCE_BANK_ACCOUNT_TRANS) to Bank Account Summary
  • Add to the pipe the grouping:
    • ACCOUNT_NUM
  • Drag the attribute ACCOUNT_NUM into Bank Account Summary from either the pipe or the input stream
  • Add an attribute:
    • Name: TotalPosTrans
    • Type: Float
    • Expression: using a forEach loop, add up the total of all positive transcations, and store it in this attribute
  • Run Bank Account Summary to test this new attribute
  • When this is working, update TotalPosTrans to also calculate the total of negative transcations, and the total of all transcations – and hold them in local variables ($variables)
  • Add two further attributes – TotalNegTrans and TotalTrans - that allow you to store the values of all negative and all transcations that you calculated in TotalPosTrans
  • Run Bank Account Summary again to test the new attributes

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

  • Use the switch() function
  • Use the forEach() function

...

  • Press the button Image Removed in the left-hand menu bar of PhixFlow – a list of all attribute functions available in PhixFlow will appear
  • Double-click on the entry for switch to bring up the help page

...

Expression: work out the transaction type description from TRANSACTION_TYPE, using a switch() statement, according to the rules below – use the examples in the help for switch() to get started

...

TRANSACTION_TYPE

...

Description

...

1

...

    1. .

      1. Type, switch(, and the inline help will appear. At the bottom of this popup is a link to its help page.

      2. TRANSACTION_TYPE

        Description

        Example Logic

        1

        "Direct Debit"

        The logic being constructed will be, where the attribute TRANSACTION_TYPE is 1 set the value for the description to be "Direct Debit".

        2

        "Standing Order"


        3

        "ePayment"


        4

        "Cheque"


        Any other value

        "Unknown"

        This will be the last value with no specified condition. If the value held in the attribute TRANSATION_TYPE is not cover in the logic above this will be the value set.


    2. Run the

...

    1. table and check that your translation of transaction type to transaction type description is correct

...

    1. .

Using forEach() to handle lists

  1. Create an aggregate

...

  1. table, with name Bank Account Summary
  2. Add a pipe from the

...

  1. table you created in the previous exercise (this

...

  1. should be called SOURCE_BANK_ACCOUNT_TRANS) to Bank Account Summary
  2. Add to the pipe the grouping:
    1. ACCOUNT_NUM
  3. Drag the attribute ACCOUNT_NUM into Bank Account Summary from either the pipe or the input

...

  1. table.
  2. Add an attribute:
    1. Name: TotalPosTrans
    2. Type: Float
    3. Expression: using a forEach() loop, add up the total of all the positive

...

    1. transactions, and store it in this attribute.
  1. Run Bank Account Summary to test this new attribute.
  2. When this is working, update TotalPosTrans to also calculate the total of negative

...

  1. transactions, and the total of all

...

  1. transactions – and hold them in local variables ($variables).
    1. See Using Variables for additional assistance. 
  2. Add two further attributes – TotalNegTrans and TotalTrans -

...

  1. use these to store the values (in your local variables) of all negative transactions and all

...

  1. transactions that you calculated in TotalPosTrans
  2. Run Bank Account Summary again to test the new attributes.