String and math expressions

Data Transformation in KNIME

Mahantesh Pattadkal

Sr. Data Scientist

Expression-based transformation

  • Allows applying custom logic
  • Manipulate data with expressions
  • Simple arithmetic to complex string manipulations

Image shows a source table with student marks, then with the expression based transformation, a new column called average score is calculated and added to the end of the table

Data Transformation in KNIME

Formulating an expression

An expression can be formulated by

  • Using operators

Image shows a lits of operators

  • Using functions

Image shows a list of a few functions

  • Combination of operators and functions

Image displays an expression that is combination of operator and functions

Data Transformation in KNIME

Expression Node

$$

Image of expression node

$$ $$ $$

  • Functions for string manipulation
  • Math formulas
  • Use a range of operators
  • Create or replace a new column
Data Transformation in KNIME

String expressions

  • Perform simple and complex string manipulations
  • Use one or more string functions

Example

replace("I loved the m@vie", "@", "o")

Output

I loved the movie
Data Transformation in KNIME

Popular string functions

Image shows list of string functions

Data Transformation in KNIME

Popular string functions

Image shows list of string functions

Data Transformation in KNIME

Popular string functions

Image shows list of string functions

Data Transformation in KNIME

Math expressions

  • Perform mathematical transformation

  • Use math operators or functions and formulas

Example

max(20, 30, 70+5)

Output

75
Data Transformation in KNIME

Popular math functions

Image shows list of mathematical functions

Data Transformation in KNIME

Popular math functions

Image shows list of mathematical functions

Data Transformation in KNIME

Popular math functions

Image shows list of mathematical functions

Data Transformation in KNIME

Mixed expressions

  • Perform string and mathematical transformation.

  • Use math and string functions together.

Example Image shows a table with two columns val1 and val2

Add a comment column Image shows a table with three columns val1, val2 and comment

Data Transformation in KNIME

Mixed expressions

Calculate minimum value

Syntax

min(column1, column2)

Expression

min($Val1$, $Val2$)

Convert it to string format

Syntax

string(input)

Expression

string(min($Val1$, $Val2$))
Data Transformation in KNIME

Mixed expressions

Syntax

join(separator, string1, string2)

Expression

join(" ", "The minimum value is", string(min($val1$,$val2$)))

Output Comment column

The minimum value is 20
Data Transformation in KNIME

Let's practice!

Data Transformation in KNIME

Preparing Video For Download...