Exploring TM1 - a Chartertech Company
Search
Close this search box.

IF Function in Turbo Integrator processes in TM1: How to Use and Syntax

IF function 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 Function for Turbo Integrator Processes

The syntax for IF function 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 function 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 Function Statements. Please see this for more information.


Use of IF Function in TI Processes

An example of the use of IF function, combined with DIMIX and DimensionElementInsert 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’. If not, then it will insert 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). The TI IF() can do up to 20 nests.

  • This field is for validation purposes and should be left unchanged.

Post Sections

Related Posts

John Vaughan

John Vaughan

John is a CPA, MBA and has been a Performance Management consultant for over 25 years. He is the founder of ExploringTM1 and highly regarded for his experience combining financial management with corporate planning, reporting and analysis. He lives in Sydney with his wife, two of his three children, their cat, Freckles, a bunch of chooks and some fish. John is a sports nut, who played rugby until he was 40, started playing football at 54 and loves being outdoors.

Leave a Reply

Your email address will not be published. Required fields are marked *

Log In