Rule related question

Post Reply
hyunjia
Posts: 64
Joined: Fri Jul 27, 2012 4:13 pm
OLAP Product: TM1
Version: 2010
Excel Version: Excel 2010

Rule related question

Post 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 ?
Catherine
Posts: 110
Joined: Wed May 20, 2009 7:30 am
OLAP Product: TM1
Version: 10.2.2 - PA
Excel Version: 2010
Location: Rennes, France

Re: Rule related question

Post 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
David Usherwood
Site Admin
Posts: 1458
Joined: Wed May 28, 2008 9:09 am

Re: Rule related question

Post 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;
Post Reply