Page 1 of 1

TM1 Rule - Mixing And Or in a If Statement

Posted: Fri Sep 01, 2017 3:52 pm
by kenship
Hi,

I made myself into some trouble when using and mixing multiple & (AND) and % (OR) in a If condition.

Let me explain:
Condition A: Change Type
Condition B: Year

If (
A = Inflation
&
B = 2018
%
B = 2019
,1%
,STET)

I meant to put 1% in 2018+Inflation and 2019+Inflation then nothing for the rest.

I realize that the way I put the rule is confusing the years. And I have to split it into 2 rules.

I wonder whether there's a way to tie it in one rule without using multiple If.

Kenneth

Re: TM1 Rule - Mixing And Or in a If Statement

Posted: Fri Sep 01, 2017 5:44 pm
by tomok
You should never hard code rates into a rule like this. I know it is really easy but once you get a rule file full of this crap it's almost impossible to maintain or add onto. Make you inflation rate an attribute of the time dimension then no IFs ANDs or BUTs are needed.

Re: TM1 Rule - Mixing And Or in a If Statement

Posted: Fri Sep 01, 2017 6:05 pm
by kenship
It's just an example. It's not even about inflation at all.

The original rule is much much longer and I believe it's not helping to provide them.

My struggle is whether I can do a Inflation & 2018 AND Inflation & 2019 without using multiple Ifs or 2 rules.

Kenneth

Re: TM1 Rule - Mixing And Or in a If Statement

Posted: Fri Sep 01, 2017 6:31 pm
by declanr
I think the high level concept you are trying to get to is just fixed by using brackets but I may not understand your question fully.

Code: Select all

['Measure']=N: If ( ( ['Thing'] = 1 % ['Thing'] = 2 ) & ( ['ymabob'] = x ), do stuff, do other stuff );

Re: TM1 Rule - Mixing And Or in a If Statement

Posted: Fri Sep 01, 2017 6:38 pm
by kenship
I'll try that, thanks a lot!