Formula operator (row-by-row) (5.0) = Formeloperator
Summary
A user-defined formula can be entered in C# syntax. This formula is then applied to each row of the input table sequentially starting at the first row. A new column is created containing the results of each row's calculation. As the operator processes the rows in a sequentially, it can refer to the calculation results of the previous rows.
Examples: Calculating a sum of values from two columns, re-formatting data, writing "if ... then ... else ..." scripts, creating "signal lights", etc.
Example: Add values from two columns
Situation | Initial data from a parent data node or an import operator or Create Table. |
Step 1 | Add an operator and select Formual operator. Insert code snippets for column references using the drop down. Choode result column name and data type of the result column. |
Step 2 | Enter formula and click "Save operator" #Length# * #Width# |
Result | |
Drop down for XIH Functions code snippets. | |
Want to learn more?
A user-defined formula can be entered in C# syntax. This formula is then applied to each row of the input table sequentially starting at the first row.
A new column is created containing the results of each row's calculation. As the operator processes the rows sequentially, it can refer to the calculation results of the previous rows.
Parameter
Using C# in TIS
C# Syntax:
- Formulas and more information under MSDN
- C# is case sensitive. Be careful with upper and lower case letters!
- Write the constant with decimal places -->
7.0
if an operation is supposed to yield a number with decimal places and you are working with constants. - class names must be fully qualified, e.g.
System.DataTime.Now
Specific in TIS:
- Variables have to be enclosed by # to be recognized.
#Length#+#Width#
means that the values of the columns "Length" are added to the values of column "Width". - Additional functions, such as the Ximes Helper (XIH) Functions and built-in variables such as
rownumber
provide additional functionality. Please refer to the sections below. - XIH Functions do NOT allow # in the notation of variables. Example: write "Identifier" instead of "#Identifier#".
Variables can be
- columns
- TIS parameters
- manual entries
NOTE: manual entries can only be named at creation time. Click into the combo box with text "Manual Entry..." and edit the text.
NOTE: manual entries must not contain spaces in their names.
Good editors for formula operator: Easier editing in the Formula Operator
Using Parameters in the Formula Operator
please see General Parameters in the "Formula Operator v04"
Further Snippets
Replacing Weekday Names depending on parameter Language | XIH.SetString("Weekday", |
HTML
Using HTML snippets is also possible and | #Column# != "Year" |
Related topics
C# functions (link)
Extensions: See XIH Functions