# Formula operator (row-by-row) (5.0) = Formeloperator

## Summary

This operator applies a formula in C# syntax to each row of the input table sequentially starting at the first row.

It creates a new column 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.

Application scenarios are summing up values from some columns, re-formatting data or applying if... then... else... conditions.

## Configuration

### Settings

## 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.

## Examples

### Example: Sum up values from previous rows

Situation | A table containing account credit and debit entries. A column should be added that indicates the account balance. |
---|---|

Settings | ... |

Result | ... |

Project File | ... |

| 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. | |

## 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#".

## Using Parameters in the Formula Operator

Parameter may be used only with XIH-Funktions, see also General Parameters in the "Formula Operator v04". Declarations in the former table below with columns, parameters and manual entries are not supported anymore.