How to check multiple condition using single if In TM1

Post Reply
k2g
Posts: 11
Joined: Tue Jun 14, 2011 4:17 am
OLAP Product: Cognos TM1
Version: 9.5
Excel Version: 2010

How to check multiple condition using single if In TM1

Post by k2g »

Hi friends,
I need to do some calculation based on multiple condition. Please tell me how to check or use multiple condition in single If.
Thanks
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: How to check multiple condition using single if In TM1

Post by Martin Ryan »

Do you mean in rules or in TI?

If in rules:
['left'] = N:
if(x=y, ['1'], if(z=q, ['2'], if(a=b, ['3'])));

If in TI:
if(a=b);
do something;
elseif(c=d);
do something else;
elseif(e=f);
something else;
else;
catch all other cases;
endif;
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
Andy Key
MVP
Posts: 352
Joined: Wed May 14, 2008 1:37 pm
OLAP Product: TM1
Version: 2.5 to PA
Excel Version: Lots
Location: Sydney
Contact:

Re: How to check multiple condition using single if In TM1

Post by Andy Key »

If you want to combine them into a single statement then & is AND, % is OR, ~ is NOT.

So in TI

Code: Select all

If( (a<5) & (b>10) );
   do true stuff;
Else;
   do false stuff;
EndIf;
in a rule

Code: Select all

['Result'] = N:
   If( (['Test 1'] > 0) % ~(['Test 2'] < 0) ),
      ['TrueValue'],
      ['FalseValue']);
Andy Key
k2g
Posts: 11
Joined: Tue Jun 14, 2011 4:17 am
OLAP Product: Cognos TM1
Version: 9.5
Excel Version: 2010

Re: How to check multiple condition using single if In TM1

Post by k2g »

Hi,
Thanks for your answer,
I want to implement any one of OR, AND, NOT in if using TI process.
k2g
Posts: 11
Joined: Tue Jun 14, 2011 4:17 am
OLAP Product: Cognos TM1
Version: 9.5
Excel Version: 2010

Re: How to check multiple condition using single if In TM1

Post by k2g »

Hi,
Can i write in TI like

IF((var1=5) % ( var1=6) % (var1=7));

to check that value of var1 is 5 or 6 or 7(i.e. using OR condiotion)?

Thanks
David Usherwood
Site Admin
Posts: 1458
Joined: Wed May 28, 2008 9:09 am

Re: How to check multiple condition using single if In TM1

Post by David Usherwood »

Yes.
Remember you need to use @= for strings.
k2g
Posts: 11
Joined: Tue Jun 14, 2011 4:17 am
OLAP Product: Cognos TM1
Version: 9.5
Excel Version: 2010

Re: How to check multiple condition using single if In TM1

Post by k2g »

Thanks David:)
Post Reply