IF in Turbo Integrator processes in TM1: Use, Syntax and Examples
IF is a function that can be used to test if an expression is true so that you can then differentially execute another function based on the outcome of the IF statement. It is able to be used in both Turbo Integrator processes and Rules, however, this post is about the use of it in TI’s only. For Rule-based IF statements, please see this post.
Syntax of IF for Turbo Integrator Processes
The syntax is a little bit complicated and looks like this:
So in this, we are testing if expression1 is true and if so, then executing statement1. If it is not true, then we are testing expression2 and if that is true, then executing statement2, and so on up to a maximum of 20 IF statements.
Note the placement of the EndIf; at the end. This tells TM1 to stop analysing the expression and gives a point where the code should restart executing after an expression has been found to be true.
Operators in TI IF Statements
We have written a blog post on the operators you can use in TI IF Statements. Please see this for more information.
Use of IF in TI Processes
If ( DIMIX ('Product',sProduct) = 0);
This will test if the current contents of a variable called sProduct exist in the dimension ‘Product’ and if not, then inserting sProduct into that Product dimension.
This version of IF() is valid only in TurboIntegrator processes only.
Note there is also an IF statement in Rules, however, the Rules IF() statement can only evaluate a single expression (with nesting available as well) and the TI IF() can do up to 20 nests.