Page 1 of 1

Help with Rule required

Posted: Sun Feb 28, 2010 10:01 pm
by Ajay
Hello All

Was wondering if any of you rule gurus could help ?

I am having some issues around how I explicitly define the area definition in my rule. What I am looking to do is write a rule that allows me to not be specific on the LHS of my rule, ie name the actual element I wish to apply a rule to, as I want it to apply to all the elements but leave it dynamic that the formula side can apply different calculations based on which intersection the rule hits.

A very simple example:

['Billing','Shirt1']=N:10;
['Billing','Shirt2']=N:20;
........
['Billing','Shirtn']=N:nn;

In my case "n" is going to be a million plus elements in the dimension so clearly I don't want a million rule lines. The example above also shows a very simple value being applied to each rule line, where in fact there will be a raft of complicated calculations.

Is there a way where I could do this:

['Billing']=N:Do calculations and circle dimension if need be to estbalish which Shirt1, Shirt2...Shirtn element to use.

or

['Billing',{group the shirt elements in some way without defining each one}]=N:apply a formulae which will differentiate between the different elements in the grouping and do the necessary calc


Any help greatly appreciated

Ajay

Re: Help with Rule required

Posted: Sun Feb 28, 2010 10:22 pm
by Martin Ryan
Not 100% sure I follow, but I think a simple if statement, probably combined with an attribute, will suffice

Code: Select all

['Billing'] = N:
if((!Shirt@='Shirt1' % !Shirt@='Shirt2', 10, stet);

OR

['Billing'] = N:
if(attrn('Shirt', !Shirt, 'Dollar Value') <>0, attrn('Shirt', !Shirt, 'Dollar Value'), continue);
Stet means leave the area as open for entry. Continue means don't apply this rule, look for other rules, further down the Rules.

HTH,
Martin

Re: Help with Rule required

Posted: Mon Mar 01, 2010 8:35 am
by Ajay
Thanks Martin.....I think my example is a bit too simple.

Using the example and taking it a bit more closer to the actual problem I have, my elements within the "Shirt" dimension need to be calculated from the values posted to other elements from another dimension, eg elements "sh" and "irt" and "number" etc.

So in my example,

sh=5
irt=5
number=1

So my rule could be
['Billing']=N:(['Sh']+['irt'])*number

So for this I would expect the "shirt1" element to be 10, but how does the rule assign this value to "Shirt1 ? What happens on "Shirtn". My gut feel is that I am going to have to add the destination element into the LHS eg.

['Billing','Shirt1']=N:(['Sh']+['irt'])*number


Note that the values for "sh" and "irt" will not always be "5" and "5" in the example above

Thanks
Ajay

Re: Help with Rule required

Posted: Mon Mar 01, 2010 8:47 am
by Steve Rowe
Hi Ajay,
It's possible you might have to post what you are wanting to do in more detail as I'm not sure the last post makes it that much clearer...

Maybe something like this

['Billing'] = N: DB ( 'CubeA', .... Attrs('Shirts', !Shirts, 'RefToCubeA'), .......)+ DB ( 'CubeB', .... Attrs('Shirts', !Shirts, 'RefToCubeB'), .......);

The !Shirts reference is the variable reference to the shirts dimesion, so at run time !Shirts becomes whichever shirt you are evaluating.
HTH???

Re: Help with Rule required

Posted: Thu Mar 04, 2010 4:55 pm
by Ajay
Sorry guys, for not getting back to you.

As usual a day away from code normally does the trick, rather like rebooting to get your feeders working properly.

I approached it a different way and hey presto, jobs a good'un

Thanks for your help though

Ajay