Versions Compared

Key

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

...

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

...

Using switch() to apply multiple tests

  • Create a new model: Attribute Scripting
  • Drag the datasource CRM onto this model
  • From the datasource open the schema browser, find the table SOURCE_BANK_ACCOUNT_TRANS and create a database collector from it
  • Create a stream from this database collector – remember to use the  button in the hover menu so that the stream attributes are automatically configured
  • Open the help for the switch() function:
    • Press Open the button section - Attribute Functions in the left-hand menu bar of PhixFlow repository – a list of all attribute functions available in PhixFlow will appear
    • Double - click on the entry for switch to bring up the help page
  • Add an attribute to this stream to hold a description of the transaction type:
    • Name: TransactionTypeDesc
    • 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

      "Direct Debit"

      2

      "Standing Order"

      3

      "ePayment"

      4

      "Cheque"

      Any other value

      "Unknown"


  • Run the stream and check that your translation of transaction type to transaction type description is correct

...

Using forEach() to handle lists

  • 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 transcationstransactions, 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 transcationstransactions, and the total of all transcations transactions – and hold them in local variables ($variables)
  • Add two further attributes – TotalNegTrans and TotalTrans - that allow you use these to store the values of all negative transactions and all transcations transactions that you calculated in TotalPosTrans
  • Run Bank Account Summary again to test the new attributes

...

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

...

  • Create a new model: Attribute Scripting
  • Drag the datasource CRM onto this model
  • From the datasource open the schema browser, find the table SOURCE_BANK_ACCOUNT_TRANS and create a database collector from it
  • Create a stream from this database collector – remember to use the Image Removed button in the hover menu so that the stream attributes are automatically configured
  • Open the help for the switch() 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
    Add an attribute to this stream to hold a description of the transaction type:
  • Name: TransactionTypeDesc
  • 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

    "Direct Debit"

    2

    "Standing Order"

    3

    "ePayment"

    4

    "Cheque"

    Any other value

    "Unknown"

  • Run the stream and check that your translation of transaction type to transaction type description is correct

...

  • 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