Conditional Formulas in TI Variables

Post Reply
User avatar
mce
Community Contributor
Posts: 352
Joined: Tue Jul 20, 2010 5:01 pm
OLAP Product: Cognos TM1
Version: Planning Analytics Local 2.0.x
Excel Version: 2013 2016
Location: Istanbul, Turkey

Conditional Formulas in TI Variables

Post by mce »

Hi,

Sorry for the simple question as I am new in TM1.
Can we use conditional formulas in defining variables with formula in TI? If yes, what is the syntax, as I could not find it in the documentation.
Can we use other functions in such formulas and where can I find the syntax for those?

Thanks in advance.

Regards,
Jeroen Eynikel
Community Contributor
Posts: 139
Joined: Mon Sep 15, 2008 1:45 pm

Re: Conditional Formulas in TI Variables

Post by Jeroen Eynikel »

Simple question, simple answer.

Yes you can use conditional functions (and a whole range of other functions in TI). Most of the functions you use in rules will also work in TI.

I would recommend you to take a look at the rules / ti functions in the reference guide (which you can access from the help menu). (the conditional function is obviously the IF function btw :))
User avatar
mce
Community Contributor
Posts: 352
Joined: Tue Jul 20, 2010 5:01 pm
OLAP Product: Cognos TM1
Version: Planning Analytics Local 2.0.x
Excel Version: 2013 2016
Location: Istanbul, Turkey

Re: Conditional Formulas in TI Variables

Post by mce »

I now realized that there is a different syntax for the functions (IF) in TI than the ones in Rules.
Thanks.
User avatar
rkaif
Community Contributor
Posts: 328
Joined: Fri Sep 05, 2008 6:58 pm
OLAP Product: IBM Cognos TM1
Version: 9.1 or later
Excel Version: 2003 or later

Re: Conditional Formulas in TI Variables

Post by rkaif »

Within the Rules use the following syntax:

Code: Select all

IF(expression, true_value, false_value)
For TI Process use the following syntax:

Code: Select all

If(expression);
statement1;
Endif;
You can also use multiple IF at a time and the syntax will be:

Code: Select all

If(expression);
statement1;
ElseIf(expression);
statement2;
ElseIf(expression);
statement3;
EndIf;
Cheers!
Rizwan Kaif
User avatar
Martin Ryan
Site Admin
Posts: 2003
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

Re: Conditional Formulas in TI Variables

Post by Martin Ryan »

It's possible to use the Rule sytax in TI too. E.g.

# This will assign the value 'One' or 'Two' to the variable v1, depending on the outcome of the condition
v1=if(v2<>v3, 'One', 'Two');

or

# This will either skip the current line, or continue processing it, depending on the outcome of the condition.
if(v2<>v3, ItemSkip, 0);

Obviously the TI version of "if" provides more flexibility (and arguably readability), but the rule way can mean less lines of code.

Martin
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
Post Reply