Page 1 of 1
How to write this Rules?
Posted: Sat Jan 11, 2014 11:42 am
by LP_user
Hi all,
I need your help to modify the Rules in our TM1 system, it is under feeders:
['dim1_elem1', 'dim2_elem1','dim3_elem1', 'final', {'PR01-1601','PR01-1602','PR01-1603','PR01-1604','PR01-1605','PR01-1606'}, '03', {'FC1','FC2','FC3', 'FC4','FC5', 'FC6', 'FC7', 'FC8','FC9', 'FC10', 'FC11', 'FC12'}] => ['dim1_elem2','12_YTD'];
In the Rule above, '03' is the Months dimension. Now we want to change the Rule to add '02' in Months dimension. And if there is number in '02', feed it further, otherwise feed the number in '03'.
Could you please guide me how to write such Rule?
Thanks a lot!
LP_user
Re: How to write this Rules?
Posted: Sun Jan 12, 2014 11:20 am
by ioscat
if you write
you will feed from both '02' and '03'. So if there is a number or fed value in '02' it will feed further. The same for '03'. If you need to feed month from previous month, use ATTRS.
Re: How to write this Rules?
Posted: Mon Jan 13, 2014 2:16 pm
by LP_user
Hi ioscat,
Thanks for your reply.
I only want to feed the number from one month. If there is a number in previous month, then feed it. Otherwise, feed the current month. So there should be one condition to decide which month to feed.
Could you please tell me how to write such condition?
Best regards,
LP_work
Re: How to write this Rules?
Posted: Mon Jan 13, 2014 2:23 pm
by tomok
LP_user wrote:If there is a number in previous month, then feed it. Otherwise, feed the current month. So there should be one condition to decide which month to feed.
Why would you care? This is a meaningless condition. Feeding from both will not result in any additional memory being used than would writing some sort of conditional feeder that looks at values and feeds from the only one that has a value. The feeders feature already does this for you and in the scenario where they BOTH have a value, feeding from both makes no difference. Once a byte has been used to mark an intersection, any additional feeding on that intersection does not increase memory consumption.
Re: How to write this Rules?
Posted: Mon Jan 13, 2014 8:44 pm
by LP_user
Hi tomok,
Thanks for your reply. Do you mean if I write the feeder as:
[..., {'02','03'}, ...]=>DB(...)
It will feed one of these two month, which has the number. And if the both month has numbers (the two numbers might be different), feeder will choose the number in the first month. Is it correct?
If the feeding mechanism works in this way, it is perfect for me. I will try it.
Best regards,
LP_user
Re: How to write this Rules?
Posted: Mon Jan 13, 2014 8:59 pm
by declanr
LP_user wrote:Do you mean if I write the feeder as:
[..., {'02','03'}, ...]=>DB(...)
It will feed one of these two month, which has the number. And if the both month has numbers (the two numbers might be different), feeder will choose the number in the first month. Is it correct?
No, what is on the left hand side will feed the same element on the right hand side, unless a different element for the same dimension is specified on the right hand side.
E.g.
Would feed ['B','01']
The curly brackets specify that it feeds for both so:
Would be like having 2 separate feeders of:
AND
Note that '01' does not feed '02' and '02' does not feed '01'.
Re: How to write this Rules?
Posted: Tue Jan 14, 2014 7:34 am
by LP_user
Hi declanr,
Thanks for your detailed explanation. It sounds that
[..., {'02','03'}, ...]=>DB(...)
won't meet my requirement.
May I use the workaround that not using feeders, instead, using normal Rules to solve my problem:
DB(...) = N: if (DB[..., {'02'}, ...]@<>0,DB[..., {'02'}, ...],DB[..., {'03'}, ...]);
Would this workaround work for me?
Best,
LP_user
Re: How to write this Rules?
Posted: Tue Jan 14, 2014 7:48 am
by declanr
LP_user wrote:May I use the workaround that not using feeders, instead, using normal Rules to solve my problem:
DB(...) = N: if (DB[..., {'02'}, ...]@<>0,DB[..., {'02'}, ...],DB[..., {'03'}, ...]);
Would this workaround work for me?
Best,
LP_user
Do you mean that you didn't have a rule statement in place before and just tried populating the numbers with a feeder?
If so it is only a rule statement that populates numbers, feeders work in conjunction with rule statements (when skipcheck is enabled) but will do absolutely nothing if there isn't a rule statement on the target cell/s.
Re: How to write this Rules?
Posted: Tue Jan 14, 2014 8:40 am
by LP_user
Hi Declan,
Sorry, I didn't describe the complete situation. There is a rule for this issue, following the feeder.
Rule:
['B'] = N:DB('A',AttrS(..,'Month'));
Feeder:
['A','01'] => ['B'];
['A','02'] => ['B'];
...
Now we want to change the Rule/Feeder, that with the condition that if previous month has the number, then feed to ['B'], otherwise, feed the current month to ['B'].
How should I change the Rule/Feeder to fulfill the task?
Thanks again for your nice help.
Best,
LP_user
Re: How to write this Rules?
Posted: Tue Jan 14, 2014 1:05 pm
by tomok
Add an attribute to the Month dimension called Next_Month and then:
FEEDERS;
['A']=>['B'];
['A']=>DB(Cube,!Dim1,!Dim2,Dimx,'B',ATTRS('Month',!Month,'Next_Month');
Re: How to write this Rules?
Posted: Tue Jan 14, 2014 1:30 pm
by LP_user
Hi Tomok,
Thanks for your hints. But I don't understand the logic in your code very well. Your feeder will do:
Feed current month of ['A'] to current month of ['B']
Then feed the current month of ['A'] to next month of ['B'].
['A','01'] => ['B','01'];
['A','01'] => ['B','02'];
['A','02'] => ['B','02'];
['A','02'] => ['B','03'];
['A','03'] => ['B','03'];
['A','03'] => ['B','04'];
...
The same month for ['B'] are feeded twice, the first time is the previous month of ['A'], the second time is the current month of ['A']. So at last, ['B'] will keep the number of the current month of ['A'].
Or do you mean, if there is no number in current month of ['A'], then
['A']=>DB(Cube,!Dim1,!Dim2,Dimx,'B',ATTRS('Month',!Month,'Next_Month');
won't work. So ['B'] will keep the number of the previous month of ['A']. Is it correct?
But if there are numbers in both previous month and current month of ['A'], ['B'] will keep the number of the current month of ['A']. It is not what I want.
Do I understand it in the right way?
But my requirement is that feed once from ['A'] to ['B']. If the previous month of ['A'] has number, then feed to ['B'], otherwise feed the current month of ['A'] to ['B']. So previous month of ['A'] is preffered to feed to ['B'].
Best regards,
LP_user
Re: How to write this Rules?
Posted: Tue Jan 14, 2014 1:41 pm
by tomok
LP_user wrote:But my requirement is that feed once from ['A'] to ['B']. If the previous month of ['A'] has number, then feed to ['B'], otherwise feed the current month of ['A'] to ['B']. So previous month of ['A'] is preffered to feed to ['B'].
Do you even understand what a feeder is? A feeder is simply a process where TM1 puts a 1 byte marker in a cell to indicate that the intersection is not empty so that when a consolidation is performed it won't be skipped by the sparse consolidation algorithm. Feeding an intersection multiple times will not change the 1 byte marker so my statement is the easiest way to do it.
Writing a rule to make a cell equal something else is not a feeder. This statement:
is not a feeder. This is the code that actually codes what values get assigned to 'A'.
This statement:
is a feeder. It will not make the values from 'B' go into 'A'. All it will do is place a one byte marker into 'A' from the matching elements in 'B'.
This is all I have to say on this topic. If you don't understand I suggest you read the TM1 Rules Guide as it is apparent you have not yet done so. Until you fully understand what a feeder is intended to do you will not "get it".