Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 6 Next »

Scenario

In an Excel table, I can add a new column that contains a formula to calculate values using data on other columns. How do I do this in PhixFlow?

Concepts

In a model, data is loaded into streams from external sources, such as files and databases. Usually we then want to calculate additional values and use them in subsequent streams. Key concepts to be aware of:

  • In PhixFlow, you use an expression to run calculations on data in order to generate different data from it.
  • Expressions refer to attributes, which are the equivelant of column headers in Excel. When you run analysis, the calculation specified is run on every record.
  • PhixFlow processes attributes in the order they are listed in the stream. If you want to use a value from an attribute, it must appear earlier in the attribute list in the stream.

Solution

  1. Create the stream and connect it to its data source or input stream.
  2. Run analysis to check that the data is loading into the stream correctly.
    At this point you can optionally run rollback to clear the data.
  3. Now add the new attributes to the stream. This is the same as adding a new column to an Excel table. Remember to set the correct data Type and Length.
  4. Make sure the Order number is greater than the attributes you want to use in the calculation.

  5. In the Expression field, write the expression to calculate the value. This is the equivalent of the Excel formula. To tell PhixFlow to use values from another attribute, specify its name using:
       _out.<name>

Example

A stream contains an attribute called GrossValue. The new attribute called NetValue, should be 75% of the gross.

In NetValue's expression, enter:   _out.GrossValue /0.75

Another way to pass values between attributes and streams is to write an expression that calculates a $-variable.

These are most useful when you need to look-up data or trigger actions that depend on the context.

See also 

  • No labels