Page 1 of 1

TM1 If Statement Help

Posted: Mon Jan 12, 2015 6:56 pm
by CapAmerica
Now as most of you already know, i'm still new to TM1 and while reading some of these postings I am unable to find out why my if statement is not working. Can any of you tell me what I am doing wrong?

Code: Select all

IF ( SCENARIO_SHORT = 'Act@Act'); SCENARIO_SHORT = '1'; ElseIf(SCENARIO_SHORT <> 'Act@Act'); SCENARIO_SHORT = '0'; ENDIF;

Re: TM1 If Statement Help

Posted: Mon Jan 12, 2015 7:13 pm
by gtonkin
When comparing against a string literal, you need to use the @ symbol in front of your operator i.e.

Code: Select all

IF ( SCENARIO_SHORT @= 'Act@Act'); SCENARIO_SHORT = '1'; ElseIf(SCENARIO_SHORT @<> 'Act@Act'); SCENARIO_SHORT = '0'; ENDIF;

Re: TM1 If Statement Help

Posted: Mon Jan 12, 2015 7:15 pm
by declanr
When doing a string comparison you need yo use "@=" or "@<>".
The elseif would also be redundant in this case; you are checking for everything that isn't covered by the original IF so just use else.

Re: TM1 If Statement Help

Posted: Mon Jan 12, 2015 7:20 pm
by AliUgur
ı think your code should be like this;

IF ( SCENARIO_SHORT @= 'Act@Act');
SCENARIO_SHORT = '1';
ELSE;
SCENARIO_SHORT = '0';
ENDIF;

Also whike you are using '@=' operator for matching the string value , you can not use ' @<>' this operator.. ' @<>' this is just for number as ı know.. The code which ı wrote at the top should be working ..

Good Luck

Re: TM1 If Statement Help

Posted: Mon Jan 12, 2015 7:26 pm
by declanr
AliUgur wrote: Also whike you are using '@=' operator for matching the string value , you can not use ' @<>' this operator.. ' @<>' this is just for number as ı know.. The code which ı wrote at the top should be working ..

Good Luck
Yes you can "@<>" is for string "<>" is for numbers. "@<>" would fail on a number comparison.

Re: TM1 If Statement Help

Posted: Mon Jan 12, 2015 9:22 pm
by CapAmerica
AliUgur, declanr, and gtonkin thank you guys my IF statement is working like a charm! Thanks again, as I forgot that I needed the @.