Page 1 of 1
How to check multiple condition using single if In TM1
Posted: Tue Jun 14, 2011 8:14 pm
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
Re: How to check multiple condition using single if In TM1
Posted: Tue Jun 14, 2011 9:12 pm
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;
Re: How to check multiple condition using single if In TM1
Posted: Tue Jun 14, 2011 11:48 pm
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']);
Re: How to check multiple condition using single if In TM1
Posted: Wed Jun 15, 2011 4:50 am
by k2g
Hi,
Thanks for your answer,
I want to implement any one of OR, AND, NOT in if using TI process.
Re: How to check multiple condition using single if In TM1
Posted: Wed Jun 15, 2011 10:39 am
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
Re: How to check multiple condition using single if In TM1
Posted: Wed Jun 15, 2011 11:09 am
by David Usherwood
Yes.
Remember you need to use @= for strings.
Re: How to check multiple condition using single if In TM1
Posted: Wed Jun 15, 2011 1:14 pm
by k2g
Thanks David:)