TM1 If Statement Help

Post Reply
CapAmerica
Posts: 15
Joined: Tue Apr 30, 2013 2:19 am
OLAP Product: Cognos TM1
Version: 10.1
Excel Version: 2010

TM1 If Statement Help

Post 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;
User avatar
gtonkin
MVP
Posts: 1199
Joined: Thu May 06, 2010 3:03 pm
OLAP Product: TM1
Version: Latest and greatest
Excel Version: Office 365 64-bit
Location: JHB, South Africa
Contact:

Re: TM1 If Statement Help

Post 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;
declanr
MVP
Posts: 1815
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: TM1 If Statement Help

Post 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.
Declan Rodger
AliUgur
Posts: 58
Joined: Tue Aug 05, 2014 2:13 pm
OLAP Product: TM1
Version: TM1 10.2.2
Excel Version: Excel 2013

Re: TM1 If Statement Help

Post 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
declanr
MVP
Posts: 1815
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: TM1 If Statement Help

Post 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.
Declan Rodger
CapAmerica
Posts: 15
Joined: Tue Apr 30, 2013 2:19 am
OLAP Product: Cognos TM1
Version: 10.1
Excel Version: 2010

Re: TM1 If Statement Help

Post 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 @.
Post Reply