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

XIH Functions

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",
(((string)XIH.GetParam("Language")) =="DE"? #Weekday# :
( #Weekday# == "1 Mo" ? "1 Mo" :
#Weekday# == "2 Di" ? "2 Tu" :
#Weekday# == "3 Mi" ? "3 We" :
#Weekday# == "4 Do" ? "4 Th" :
#Weekday# == "5 Fr" ? "5 Fr" :
#Weekday# == "6 Sa" ? "6 Sa" :
#Weekday# == "7 So" ? "7 Su" : "???" )))

HTML

Using HTML snippets is also possible and
sometimes necessary. For example 
using the € sign directly is not possible
due to encoding but with HTML (€) it works 
well.

#Column# != "Year" 
? XIH.SetString("Value", #Value# + " €")
: XIH.SetString("Value", #Value#.Substring(0,#Value#.Length-3))

Related topics

C# functions (link)

Extensions: See XIH Functions