IF() TM1 TI Function: Use and Syntax

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:

If (expression1);
statement1;
ElseIf (expression2);
statement2;
ElseIf (expressionN);
statementN;
EndIf;

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.

Use of IF() in TI Processes

An example of the use of IF is as follows:

If ( DIMIX ('Product',sProduct) = 0);

DimensionElementInsert ('Product,'',sProduct,'s');

EndIf;

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.

If you like this post, please spread the love…

Leave a Reply

  1. Pingback: DIMIX TM1 Function: Use and Syntax - Exploring TM1

  2. Pingback: Use and Syntax of TM1 Function DimensionElementInsert

  3. Pingback: ELLEV TM1 Function: Use and Syntax - Exploring TM1

  4. Pingback: Null Values in a Turbro Integrator Process - Exploring TM1

  5. Pingback: ItemSkip TM1 Function: Use and Syntax - Exploring TM1

  6. Pingback: Operators in TI IF Statements - Exploring TM1

  7. Pingback: Use and Syntax of TM1 Function ELISANC

  8. Pingback: Use and Syntax of TM1 Rule Function IF()

  9. Pingback: Checking if a DimensionExists in a TM1 Model - Exploring TM1

  10. Pingback: Using the DimensionCreate Function to Create a Dimension in TM1 - Exploring TM1

  11. Pingback: Date and Time Functions in TM1 10.2 - Exploring TM1