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:
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.
- 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.
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.
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.
Records that meet the condition will be routed to the upper data bus, and the remaining records to the lower data bus.
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.
After entering the condition, you can test its behavior using the Test button.
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.
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.