Page 1 of 1

Sets in rules

Posted: Tue Aug 27, 2013 10:44 am
by tm1support
Hi, just trying to get some help with rule and feeder statements when sets are used.

With a rule/feeder the right hand side is determined by the elements on the left hand side - the right resolves based on what's on the left? eg,

['2013', 'CompanyB', 'Product1', 'Sales'] = [!Year, 'CompanyA', !Products, !Measures];
['2013', 'CompanyA', 'Product1', 'Sales'] => [!Year, 'CompanyB', !Products, !Measures];

Does this also apply when there are sets of elements on the left? eg

[{'2013', '2014'}, 'CompanyB', 'Product1', {'Sales', 'Cost'}] = [!Year, 'CompanyA', !Products, !Measures];

When there are such sets do the feeders work on the same principle - eg

[{'2013', '2014'}, 'CompanyA', 'Product1', {'Sales', 'Cost'}] => [!Year, 'CompanyB', !Products, !Measures];

or would this cause overfeeding as the right side of the feeder doesn't resolve the individual elements and as such '2013 and '2014' feed all the !Year elements and likewise 'Sales' and 'Cost' feed all the measure elements?

Thanks

Re: Sets in rules

Posted: Tue Aug 27, 2013 11:21 am
by AmbPin
Hello,
Is your example correct:-

Code: Select all

['2013', 'CompanyB', 'Product1', 'Sales'] = [!Year, 'CompanyA', !Products, !Measures];
['2013', 'CompanyA', 'Product1', 'Sales'] => [!Year, 'CompanyB', !Products, !Measures];
If we assume that you have years in your time dimension before 2013 then I believe that

Code: Select all

['2013', 'CompanyB', 'Product1', 'Sales']
would be set with data from whichever year the rule engine encounters first. The situation would the same for products so '2013' 'Product1' would be set with data for whichever product is encountered first.
If this rule is to make CompanyB Sales = those for CompanyA then would it not in the simplest form look like:-

Code: Select all

['CompanyB'] = ['CompanyA'] 
['CompanyA'] => ['CompanyB']
If you wanted to restrict time then you could do this with and IF statement.

Re: Sets in rules

Posted: Tue Aug 27, 2013 11:59 am
by tm1support
Thanks AmbPin.

Still working on a better understanding of rules and the example I gave is just a simplified rule - but does work with the tests I've done - ie CompanyB = CompanyA for 2013 and the same for 2014.

When you say:
set with data from whichever year the rule engine encounters first
do you mean if I had 2010 in my year dimension then if the rule encounters it first it will return the 2010 data in CompanyB for 2013? I'm not sure this would be the case if the right side of the rule uses what's on the left.

If I use ['CompanyB'] = ['CompanyA'] wouldn't that override consolidations as well? Besides it is only required for a certain products and measures - not a complete replication.

The query is really around using sets and whether they can be written into the feeder statement without causing overfeeding or underfeeding.

Re: Sets in rules

Posted: Tue Aug 27, 2013 12:36 pm
by tomok
tm1support wrote:Hi, just trying to get some help with rule and feeder statements when sets are used.

With a rule/feeder the right hand side is determined by the elements on the left hand side - the right resolves based on what's on the left? eg,

['2013', 'CompanyB', 'Product1', 'Sales'] = [!Year, 'CompanyA', !Products, !Measures];
['2013', 'CompanyA', 'Product1', 'Sales'] => [!Year, 'CompanyB', !Products, !Measures];

Does this also apply when there are sets of elements on the left? eg

[{'2013', '2014'}, 'CompanyB', 'Product1', {'Sales', 'Cost'}] = [!Year, 'CompanyA', !Products, !Measures];

When there are such sets do the feeders work on the same principle - eg

[{'2013', '2014'}, 'CompanyA', 'Product1', {'Sales', 'Cost'}] => [!Year, 'CompanyB', !Products, !Measures];

or would this cause overfeeding as the right side of the feeder doesn't resolve the individual elements and as such '2013 and '2014' feed all the !Year elements and likewise 'Sales' and 'Cost' feed all the measure elements?

Thanks
No, this does not cause overfeededing. Using sets like you have with the set on the left hand side (which really tells TM1 which area of the cube is affected by the rule) and the bang (!) notation on the right you are just applying the rule to 2013 and 2014, using the corresponding years on the right. The same holds true for the way you wrote the feeder.

Re: Sets in rules

Posted: Tue Aug 27, 2013 12:43 pm
by tm1support
Much appreciated Tomok. That's cleared it up for me.