Versions Compared

Key

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

...

Scenario

We want to use data to evaluate a new set of values and to add the values to a new attribute.

Stream with list of attrs → stream + attr

Calculation in expression to give a $ variable

Solution:

  • how to

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.

Solution

  1. Create the stream and connect it to its data source or input stream.
  2. Run analysis to check that the input data is loading into the stream correctly.
    At this point you can optionally run rollback to clear the data; see Rollback 13 Rolling back Streams
  3. Now add the new attributes to the stream. These are like the Excel columns. Remember to set the correct data Type and Length.
  4. Make sure the order Order number is greater than the attributes loaded via the input pipe. 

    Tip

    PhixFlow processes attributes in the order they are listed in the stream. If you want to use a value from another attribute it must appear earlier in the attribute list.


  5. In the Expression field, write the expression to calculate the value. This is the equivalent of the Excel formula. Specify the value to use in the calculation with _out.<name>
    For example, to set the attribute have a value that is 75% of the value in an earlier attribute, write the expression:  _out.<name> /0.75


For information about:



$-variables
To use the value of a context parameter
Can be useful in a lookup


Context parameters

Which country

Which Date

Ref _context.CountryCode - relates to the parameter


Calculation in expression to give a $ variable

Image Added