Page 1 of 1
Rule related question
Posted: Fri Aug 17, 2012 7:20 am
by hyunjia
Hi All
I am relatively new breed in the TM1 community. I came across a sample from the TM1 rule manual and got confused. Please see below rule to calculate a average cost in inventory cube.
['Average Purchase Price/Kg' ] =['Purchase Cost' ] \ ['Quantity in Stock - Kgs' ] ; C:0;
Why add 'C:0' at the end of the statement ? what kind of reason or behavior would it impact during calculation ?
Re: Rule related question
Posted: Fri Aug 17, 2012 8:16 am
by Catherine
Hi,
The right syntax would be:
['Average Purchase Price/Kg' ] = N:['Purchase Cost' ] \ ['Quantity in Stock - Kgs' ] ; C:0;
And it would mean that your average cost would be calculated only at leaf levels, and you would see 0 on all consolidations.
I think it makes sense to calculate an average cost at all levels. That's why I would simply write:
['Average Purchase Price/Kg' ] = ['Purchase Cost' ] \ ['Quantity in Stock - Kgs' ] ;
HTH
Re: Rule related question
Posted: Fri Aug 17, 2012 8:23 am
by David Usherwood
Not for the first time, IBM's TM1 documentation is 'flawed' (I could be more vivid

)
Rules with n: apply only at base level (of all dimensions). Most rules you will write need this.
Rules with <nothing> apply at all levels. Normally this only works properly if you are dividing by something. I call these 'KPI' rules.
Rules with c: apply only when one or more dimensions are
not at base level. They are pretty rare.
In this case, because the first rule is <nothing>, the c: won't do anything. Also, this is a 'KPI' rule, so <nothing> is right.
The correct syntax would be - say:
Code: Select all
['Units'] =
n: ['Value'] / ['Price'];
c: 0;
Assuming, here, that summing units isn't meaningful.
Personally I prefer setting AllowSeparateNandCRules = T in tm1s.cfg and writing
Code: Select all
['Units'] = n: ['Value'] / ['Price'];
['Units'] = c: 0;