Search

Home

Home

IF

IF

The IF operator conditionally splits data on the bus according to logical criteria you define. It examines each record in the input bus and checks whether it matches the condition set in the operator’s configuration.

Depending on the result:

  • the data goes to the upper output bus if all records meet the condition
  • if even a single record fails the condition, the whole bus is redirected to the lower output bus.

If the operator is configured to separate data according to the condition, then:

  • records that satisfy the condition are routed to the upper bus (TRUE output),
  • records that fail the condition are routed to the lower bus (FALSE output).

You can chain IF operators to build complex, multi-variant logical paths, enabling selective data processing in advanced decision-making scenarios.

An example GRAVITY project with the IF operator:

image

CONFIGURING THE OPERATOR

The first step is to decide whether the operator should work in Run only one busbar mode or Split the data into two busbars mode.

  • Choose Run only one busbar option if you want the data stream to be redirected to only one of the output buses.
  • image

    If even one record fails the condition, the whole data stream is sent to the lower bus.

    If all records meet the condition, the data will be routed to the upper bus.

    icon
    When the Run only one busbar option is used, the system will execute only the project path connected to the data bus to which the data stream was routed.

    By selecting the Run only one busbar option, you can also use Single execution mode, which ensures that the operator is executed only once. In this mode, the conditional algorithm cannot use bits from the input data bus. You can, however, use project parameters and global variables.

  • Select the Split the data into two busbars option if you want records to be split into two buses depending on whether the condition is met.
  • image

    Records that meet the condition will be routed to the upper data bus, and the remaining records to the lower data bus.

    icon
    When the Split the data into two busbars option is used, the system always executes both processing paths, regardless of whether any data was passed to them or not. The upper path (true) is executed first, and only after the entire upper path has finished processing is the lower path (false) executed.

BUILDING AND TESTING THE CONDITION

The operator processes each data bus record according to the condition entered in the Condition field. The condition is written in C# and represents the body of a function that returns a bool value; therefore, the condition code must return true or false. Within the condition, you can use data bus bits, project parameters, global variables, as well as functions.

Available functions:

  • GET_AGGR → the sum of the values of the specified data bus column for all input data
  • GET_OUTTEMP_AGGR → the sum of the values of a data column collected in the OUTPUT_TEMPORARY set
  • IS_OPERATOR_EXECUTED → returns true if the specified operator used in the project has already been executed, and false otherwise.
image

After entering the condition, you can test its behavior using the Test button.

icon
During algorithm testing, default values are substituted for data bus bits, project parameters, and aggregate functions. For individual data types, the following values are used:

DateTime → DateTime.Now string → "Text" double → 1.0 int → 1; bool → true

You can change the default values in the form that is displayed after clicking the Test button.

image

During data processing by the operator, if the condition is met, the data stream will be routed to the upper output bus; otherwise, the data stream will flow through the lower bus. On the lower bus, a bit named __ifResult__ is added, which stores the result of the condition evaluation for the record.

icon
Because the operator works directly on records from the input data bus, if no records are present on the data bus, the operator cannot perform any condition evaluation. In this case, regardless of the defined condition, the processing flow will always be routed to the lower output bus (false). This does not apply to Single execution mode, in which one condition check is always performed.