Page 1 of 1

Different rules need to be taken in account for 1 measure

Posted: Wed Oct 20, 2010 2:22 pm
by bmeer31
Hi,

we have the following challenge in our company model:
One measure KG need to be calculated by using different rules.

The activation of rules is leading by dimension elements.

Our challenge in rules:

Element FS + AREA#1 till AREA#4

['KG DAY',{'FS'}, {'AREA#1','AREA#2','AREA#3','AREA#4'}] = N:ROUNDP(if (['DAY % (REG)'] + ['CTR % (REG)'] = 0,
if (['DAY % (QAD)'] + ['CTR % (QAD)'] = 0,0,['DAY % (QAD)']),['DAY % (REG)']) * ['KG (DEM)'],0);

Element FS + AREA#5 till AREA#10

['KG DAY',{'FS'}, {'AREA#5','AREA#6','AREA#7','AREA#8','AREA#9','AREA#10'}] = N:ROUNDP(if (['DAY % (CUS)'] + ['CTR % (CUS)'] = 0,
if (['DAY % (REG)'] + ['CTR % (REG)'] = 0,0,['DAY % (REG)']),['DAY % (CUS)']) * ['KG (DEM)'],0);


The AREA elements are part of a dimension hierarchy and is not de lowest level. The total hierarchy consist out of 5 levels and Area is the 4th level.

Our calculation needs to work up to lowest level (level 0).
With the rules we don't get the right results. Results are only shown up to Area level.

Can someone give use advise?

Thanks,

Barbara

Re: Different rules need to be taken in account for 1 measur

Posted: Wed Oct 20, 2010 2:56 pm
by Michel Zijlema
Hi Barbara,

Probably the easiest way to do this is to add an attibute to the dimension containing the AREA# elements, defining the calculation method on the lowest level and then use a rule that checks this attribute, f.i.:

['KG DAY','FS'] = N:
IF(AttrS('areadim',!areadim, 'CalcMethod') @= 'type1',
ROUNDP(if (['DAY % (REG)'] + ['CTR % (REG)'] = 0, if (['DAY % (QAD)'] + ['CTR % (QAD)'] = 0,0,['DAY % (QAD)']),['DAY % (REG)']) * ['KG (DEM)'],0),
ROUNDP(if (['DAY % (CUS)'] + ['CTR % (CUS)'] = 0, if (['DAY % (REG)'] + ['CTR % (REG)'] = 0,0,['DAY % (REG)']),['DAY % (CUS)']) * ['KG (DEM)'],0));


Michel

Re: Different rules need to be taken in account for 1 measur

Posted: Wed Oct 20, 2010 3:01 pm
by kpk
You can split the calculation on the other side of the rule with a conditional statement.
I mean you can define an attribute (probably a A/B flag enough in your case) for each AREA elements and use that flag to define the required calculation.
You can use the ELPAR() function instead of the ATTRS() if you are sure that there is only one parent for each element or the order of the parents are fixed and will be not changed.

['KG DAY',{'FS'}] = N:
IF(ATTRS('AREA',!AREA,'TYPE')@='A',
ROUNDP(if (['DAY % (REG)'] + ['CTR % (REG)'] = 0,
if (['DAY % (QAD)'] + ['CTR % (QAD)'] = 0,0,['DAY % (QAD)']),['DAY % (REG)']) * ['KG (DEM)'],0),
ROUNDP(if (['DAY % (CUS)'] + ['CTR % (CUS)'] = 0,
if (['DAY % (REG)'] + ['CTR % (REG)'] = 0,0,['DAY % (REG)']),['DAY % (CUS)']) * ['KG (DEM)'],0)
);

Re: Different rules need to be taken in account for 1 measur

Posted: Thu Oct 21, 2010 12:44 pm
by bmeer31
Thanks for your replies!

Regards,

Barbara