Conditional statements and logical operators

Data Transformation in KNIME

Mahantesh Pattadkal

Sr. Data Scientist

About me

Image of the myself

Image describing my experience with KNIME

Data Transformation in KNIME

Conditional statements

  • Allow you to assign values based on a condition
  • If the condition is not met, assigns default value
  • Example: IF Statement
Data Transformation in KNIME

IF statement

  • Allows specifying one or more conditions
  • Value 1 is assigned if condition one is met
  • Assigns default value if all conditions fail

Syntax

IF(condition_1, value_1, additional_conditions, value_if_all_false)
Data Transformation in KNIME

Comparison operators

Operators are used to compare column values to

  • Values of other columns
  • Constant values

A table displaying comparison operators

Data Transformation in KNIME

Comparison operators

Add "Age group" column

  • "Adult" when the age is greater than 18
  • "Non-Adult" if the age is lower than 18

Table describing name and age for 3 persons

Syntax:


IF($Age$>18,"Adult","Non-Adult")

Output:

Table showing name, age and age group for 3 persons

Data Transformation in KNIME

Logical operators

  • Combines two or more conditional statements
  • Enables using complex expressions
  • Outputs a boolean value

AND

Returns True if all the conditions are met

OR

Returns True if any of the conditions are met

NOT

Returns the negation of boolean expression

Data Transformation in KNIME

Logical operators

An icon of a calender

Assign the tag as a weekend

  • Condition 1: If the day is "Sunday"
  • Condition 2: If the day is "Saturday"

Syntax

IF($Day$="Saturday" OR $Day$="Sunday", "Weekend", "Weekday")
Data Transformation in KNIME

Cell splitting

  • Split the cell values into two or more columns
  • Specify a delimiter to split the cell values

Image showing a column residence being split into two columns city and country.

Data Transformation in KNIME

Our dataset

Image of a person looking for furnitures on his laptop.

Orders data from KIA - Online furniture shopping company

  • Order ID
  • Customer ID, Email ID
  • Customer Location
  • Furniture category and product name
  • Cost of product
  • Sales price of the product
Data Transformation in KNIME

Let's practice

Data Transformation in KNIME

Preparing Video For Download...