- 1 Minute to read
- Print
- DarkLight
- PDF
QQ - How do I use Conditional and IF statements in DataJet?
- 1 Minute to read
- Print
- DarkLight
- PDF
There are 4 mechanisms for working with Conditional Statements in DataJet:
- Engineering | Functions | FLogic functions
- Engineering | Functions | LMath
- Engineering | Expression Field | Conditional functions
- Script | Editor | IF ELSE ENDIF Methods
FLogic
FLogic functions are designed to rapidly evaluate conditional functions on large volumes of data, and are an efficient way of executing logical processing. They are accessed from the Engineering | Functions menu:
Selecting an FLogic function will bring up the Engineering Function Dialog:
These functions are analagous to IF statements. The logic of these functions can be thought of as follows:
- If(A=B, 1, 0)
- If A = B, then 1, Else 0
The output of an FLogic function is a new dataset.
For more information, see FLogic Overview
LMath Functions
Conditional selection of either C or D, based on value of A and B
- If(A>B, C, D)
- If A > B, then C, Else D
Expression Field
Engineering | Expression Field will open the Expression Field dialog which offers various conditional functions, including:
- between (value, lower, upper)
- if (cond, tval, fval)
- ifs(cond, value, cond, value, final)
- isnull (x)
IF ELSE ENDIF
Script Editor supports conditional processing for the IF ELSE ENDIF method. Find this on the Script Editor | Tools menu
[
{
"method": "IF",
"condition": "%StartRow%==0 && %EndRow%==0",
"project": "project"
},
{
"method": "ELSE",
"project": "project"
},
{
"method": "ENDIF",
"project": "project"
}
]
IF "condition" can be "true" or "false" (and hence form a conditional execution, especially useful with DEFINES, also known as variables).
For more information on IF ELSE ENDIF, see IF ELSE ENDIF