Using If-else Condition

Using If-else Condition

To use the If Else condition, follow the steps given below.

  1. Open the required workbook or create a new workbook. The selected workbook canvas is displayed.

  2. Add the reader/dataset, if not already present in your workbook.

  3. Drag-and-drop or double-click the If Else node from Condition into the workbook canvas.



To create a sample workbook using If Else Condition, follow the steps given below.
  1. Connect the reader to the If Else node.
  2. Drag-and-drop or double-click the algorithm for which you want to test the Task Pane condition into the workbook canvas. Refer to Building Algorithm Flow in a Workbook Canvas.
  3. Click the algorithm node and select the Properties displayed on the right-hand side.
  4. Connect the If Else node to the algorithm.
  5. Connect the algorithm node to the End node.

    (info)
    Note
    :

    The algorithms should always be inserted between the Condition and the End node.

  6. Click the If Else node and select the Properties displayed on the right-hand side. 
  7. Click the End node and select the Properties displayed on the right-hand side.
  8. Click the Save icon () on the function pane of the workbook to save the workbook.
  9. Click the Run icon () on the Function Pane of the workbook to run the workbook. A sample workbook using the If Else condition is shown below.



    The algorithms are executed based on the conditions selected for If Else. If the condition evaluates to True, the algorithms selected in the If Tasks are executed, else the algorithms selected in the Else Tasks are executed.

If Else Condition Properties

The If Else Condition Properties show Task Name fields, Clause fields associated with it, Else Condition check box, and Else Condition Tasks.


The table given below describes the functions present on the If Else condition.

Field Name

Description

Remark

Task Name

It is the name of the condition selected (If Else).

If Tasks 

It lets you select the successor tasks which are to be executed if the condition given in If Else evaluates to True.

You can select more than one task.

Clause

It lets you create a complex condition.

You can add more than one clause.

Clause

Parameter

It lets you select the variable that you have added.

Refer to Adding a Variable


Condition

It lets you select the mathematical operator for the variable that you have added.

The available options are >, <, !=, ==, <=, and >=.


Value

It lets you enter the required values to test or execute the successor algorithms connected to the If Else condition.

This value is compared with the Current Value of the added variable to evaluate the expression.

Else Condition  

This check box allows you to add successor tasks that are to be executed if the condition given in If Else evaluates to False.

Else Condition Tasks 

It lets you select the successor tasks which are to be executed if the condition given in If Else evaluates to False.

You can select more than one task.

The figure given below is an example of If Else Properties. The selected condition is If Else, and the algorithms connected to the If Else node are Decision Tree and Linear Discriminant Analysis.


In the example above, the variable added is Test1 with the Current Value of 10. The If condition selected for the variable is Test1 == 10. In this example, the value of Test1 is 10, hence the Decision Tree algorithm is executed. If we change the value of the variable Test1 to anything other than 10, then the Linear Discriminant Analysis algorithm would be executed.

End Properties

You should always end any condition which you have selected. The End Properties show the Task Name field and End tasks.
The Task Name is End. In the End tasks, you have to select the conditions which are to be ended.


(info) Note:

When you drag-and-drop or double-click the If Else or While condition, the End node is also inserted into the workbook canvas along with it.

The table given below describes the functions present on the While condition.

Field Name

Description

Remarks

Task Name

It is the name of the task (End).

End Tasks

It lets you select the tasks you want to end.

Connect the algorithms whose execution you want to stop to the End node.

Assign Resultant Variable

It lets you select the user-defined variables to which you can assign the result of the algorithm that is executed.


    • Related Articles

    • Using If-else Condition

      To use the If Else condition, follow the steps given below. Open the required workbook or create a new workbook. The selected workbook canvas is displayed. Add the reader/dataset, if not already present in your workbook. Drag-and-drop or double-click ...
    • If Else

      Using If Else condition in flow control To use the If Else condition, follow the steps given below. Open the required workbook or create a new workbook. The selected workbook canvas is displayed. Add the reader/dataset, if not already present in your ...
    • If Else

      Using If Else condition in flow control To use the If Else condition, follow the steps given below. Open the required workbook or create a new workbook. The selected workbook canvas is displayed. Add the reader/dataset, if not already present in your ...
    • Using While Condition

      To use the While condition, follow the steps given below. Open the required workbook or create a new workbook. The selected workbook canvas is displayed. Add the reader/dataset, if not already present in your workbook. Drag-and-drop or double-click ...
    • Using While Condition

      To use the While condition, follow the steps given below. Open the required workbook or create a new workbook. The selected workbook canvas is displayed. Add the reader/dataset, if not already present in your workbook. Drag-and-drop or double-click ...