Versions Compared

Key

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

Scenario

In an Excel table

Insert excerpt
_Banners
_Banners
nameanalysis
nopaneltrue

Overview

In a spreadsheet such as MS Excel, I can add a new column that contains a formula to calculate values using data

on

in other columns. How do I do this in PhixFlow

.Concepts

?

In a PhixFlow analysis model, data is loaded into

streams

tables from external sources, such as files and databases. Usually we

then

want to calculate additional values and use them in subsequent

streams

tables. 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.
  • The expression is in an attribute, which is like a column header in Excel.
  •  When you run the analysis model, PhixFlow runs the calculation on every record, adding the data to each cell in the attribute's column. 
  • PhixFlow processes attributes in the order they are listed in the table. If you want to use a value from an attribute, it must appear earlier in the attribute list in the table.

Solution

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

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.

In the Expression field
  1. table, set the following:
    1. Name, of the attribute. This will be used to reference this attribute in other expressions.
    2. Type, the data type pf the attribute such as String or Decimal.
    3. Length, specifies the length of the string if the data type is selected.
    4. Order, sets the position of the new attribute in the table. If left black the attribute will be added to the end. Attributes can only reference the processed values of attributes which appear before this one.
    5. Expression, 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 Removed
    1. To tell PhixFlow to use processed values from another attributes, specify its name using:
         _out.<name>. Use the in prefix to use unprocessed values.
    2. Image Added


Example

A table contains an attribute called GrossValue. A new attribute for the net value should be 75% of the gross.

Create the attribute NetValue and in the expression, enter:   _out.GrossValue * 0.75


Tip

Another way to pass values between attributes in a table is to write an expression that calculates a $-variable. These are most useful when the value you want depends on context. This can be the case when looking-up data or triggering actions.

More Information