cost allocation via TI
Posted: Mon Jan 26, 2015 11:26 am
Hi, I have a Problem where I am trying to get around for some time and now hoping for some assistance from this Group.
Here the Business Situation:
I have a cube where I am loading the Revenue and direct cost by customer Level where the cost is directly assigned to the customer. I have then also further cost, which needs to be allocated to the customers. To do this, I am loading the total cost by GL account and cost Center, on a source code which is outside of the "All_Source" consolidation. I have then written a rule, which calculates the difference of the total cost by cost center and GL account and total cost by customer, cost center and GL account and then allocates this difference by the customer revenue splits in the cost center ( for example the difference of 100 will be allocated to customer 1 with 60, as he makes 60% of the revenue in the cost center and the customer 2 with 40%)
Here is the rule and the feeders, the rule has 2 parts - the 2nd part is for situations where there is no revenue. Also, the customer revenue share is calculated on a specific Source type (NR) because, here I uploaded only positive revenues to do the splitting on positive revenue only)
# Allocation rule part
[ 'SOURCE':'ALO'] = N: IF(ELISANC('ACCT', !ACCT, '5999 - TOTAL DIRECT COST')=0,
( DB('GPC_1', 'OTH', 'PS', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, !ACCT, !PROD, '9999999999') -
DB('GPC_1', 'ALL_CUST_TYP', 'HEX', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, !ACCT, !PROD, 'ALL_CUSTOMER'))
*
(
DB('GPC_1', !CUST_TYP, 'NR', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, 'STAFFING / INTERIM REVENUE', 'ALL_PROD', !CUST ) \
DB('GPC_1', 'ALL_CUST_TYP', 'NR' , !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, 'STAFFING / INTERIM REVENUE', 'ALL_PROD', 'ALL_CUSTOMER' )
), continue );
[ 'SOURCE':'ALC','9999999999'] = N: IF(ELISANC('ACCT', !ACCT, '5999 - TOTAL DIRECT COST')=0,
IF( DB('GPC_1', 'ALL_CUST_TYP' , 'NR', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, 'STAFFING / INTERIM REVENUE', 'ALL_PROD', 'All_CUSTOMER' )=0,
(DB('GPC_1', !CUST_TYP, 'PS', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, !ACCT, !PROD, '9999999999' ) -
DB('GPC_1', !CUST_TYP, 'HEX', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, !ACCT, !PROD, 'ALL_CUSTOMER' )) ,0) ,0);
FEEDERS;
['STAFFING / INTERIM REVENUE'] => DB('GPC_1', !CUST_TYP, 'ALO', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, '5999 - TOTAL DIRECT COSTS', 'ALL_PROD', !CUST );
[ 'HR_FED'] => DB(IF( DB('GPC_1', 'ALL_CUST_TYP' , 'ALL_SOURCE', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, 'STAFFING / INTERIM REVENUE', !PROD, 'All_CUSTOMER' )<>0, '',
IF( (DB('GPC_1', !CUST_TYP, 'PS', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, !ACCT, !PROD, '9999999999') -
DB('GPC_1', !CUST_TYP, 'HEX', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, !ACCT, !PROD, 'ALL_CUSTOMER' )) =0, '',
'GPC_1')), !CUST_TYP, 'ALC', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, '5999 - TOTAL DIRECT COSTS', !PROD, '9999999999' );
The rule works fine and the results are as expected, however as you can see I had to use a consolidation element in the feeder and this makes the cube quite big and slow. I have worked some time on improving the rule, even tried conditional feeder as you can see in the 2nd part, but with no major improvement.
Because of this, I then tried to go from rule to TI.
Again, I managed to get a result by using this calculation in the TI. See here the part for the 1st rule part:
vSource='ALO';
vDiff=cellgetn('GPC_1','OTH', 'PS', BUSINESS_UNIT, V4, PERIODE, Business_Typ, DEPT, ACCT, PROD, '9999999999') - cellgetn('GPC_1','ALL_CUST_TYP', 'HEX', BUSINESS_UNIT, V4, PERIODE, Business_Typ, DEPT, ACCT, PROD, 'ALL_CUSTOMER');
vSpread=cellgetn('GPC_1',CUST_TYP, 'NR', BUSINESS_UNIT, V4, PERIODE, Business_Typ, DEPT, 'STAFFING / INTERIM REVENUE', 'ALL_PROD', CUST) / cellgetn('GPC_1','ALL_CUST_TYP', 'NR', BUSINESS_UNIT, V4, PERIODE, Business_Typ, DEPT, 'STAFFING / INTERIM REVENUE', 'ALL_PROD', 'ALL_CUSTOMER') ;
vValue=vDiff * vSpread;
CellPutN(vValue,'GPC_1',CUST_TYP,vSource,BUSINESS_UNIT,V4,PERIODE,BUSINESS_TYP,DEPT,ACCT,PROD,CUST);
When I am running this as a test on a close range of test data all works fine, when I am running this on a bigger range, the TI runs forever. I am guessing I need to build in some looping, so that the code goes thru the data and not pulls the data in a view and then working up the calculations, but I am not sure and not really familiar with building a code which loops thru the code.
Any helps you guys can give me on this, either rule or TI, is greatly appreciated.
If my details are confusing and you need further explanations, please advise
Regards Manfred
Here the Business Situation:
I have a cube where I am loading the Revenue and direct cost by customer Level where the cost is directly assigned to the customer. I have then also further cost, which needs to be allocated to the customers. To do this, I am loading the total cost by GL account and cost Center, on a source code which is outside of the "All_Source" consolidation. I have then written a rule, which calculates the difference of the total cost by cost center and GL account and total cost by customer, cost center and GL account and then allocates this difference by the customer revenue splits in the cost center ( for example the difference of 100 will be allocated to customer 1 with 60, as he makes 60% of the revenue in the cost center and the customer 2 with 40%)
Here is the rule and the feeders, the rule has 2 parts - the 2nd part is for situations where there is no revenue. Also, the customer revenue share is calculated on a specific Source type (NR) because, here I uploaded only positive revenues to do the splitting on positive revenue only)
# Allocation rule part
[ 'SOURCE':'ALO'] = N: IF(ELISANC('ACCT', !ACCT, '5999 - TOTAL DIRECT COST')=0,
( DB('GPC_1', 'OTH', 'PS', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, !ACCT, !PROD, '9999999999') -
DB('GPC_1', 'ALL_CUST_TYP', 'HEX', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, !ACCT, !PROD, 'ALL_CUSTOMER'))
*
(
DB('GPC_1', !CUST_TYP, 'NR', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, 'STAFFING / INTERIM REVENUE', 'ALL_PROD', !CUST ) \
DB('GPC_1', 'ALL_CUST_TYP', 'NR' , !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, 'STAFFING / INTERIM REVENUE', 'ALL_PROD', 'ALL_CUSTOMER' )
), continue );
[ 'SOURCE':'ALC','9999999999'] = N: IF(ELISANC('ACCT', !ACCT, '5999 - TOTAL DIRECT COST')=0,
IF( DB('GPC_1', 'ALL_CUST_TYP' , 'NR', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, 'STAFFING / INTERIM REVENUE', 'ALL_PROD', 'All_CUSTOMER' )=0,
(DB('GPC_1', !CUST_TYP, 'PS', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, !ACCT, !PROD, '9999999999' ) -
DB('GPC_1', !CUST_TYP, 'HEX', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, !ACCT, !PROD, 'ALL_CUSTOMER' )) ,0) ,0);
FEEDERS;
['STAFFING / INTERIM REVENUE'] => DB('GPC_1', !CUST_TYP, 'ALO', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, '5999 - TOTAL DIRECT COSTS', 'ALL_PROD', !CUST );
[ 'HR_FED'] => DB(IF( DB('GPC_1', 'ALL_CUST_TYP' , 'ALL_SOURCE', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, 'STAFFING / INTERIM REVENUE', !PROD, 'All_CUSTOMER' )<>0, '',
IF( (DB('GPC_1', !CUST_TYP, 'PS', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, !ACCT, !PROD, '9999999999') -
DB('GPC_1', !CUST_TYP, 'HEX', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, !ACCT, !PROD, 'ALL_CUSTOMER' )) =0, '',
'GPC_1')), !CUST_TYP, 'ALC', !BUSINESS_UNIT, !YEAR, !PERIODE, 'MP', !DEPT, '5999 - TOTAL DIRECT COSTS', !PROD, '9999999999' );
The rule works fine and the results are as expected, however as you can see I had to use a consolidation element in the feeder and this makes the cube quite big and slow. I have worked some time on improving the rule, even tried conditional feeder as you can see in the 2nd part, but with no major improvement.
Because of this, I then tried to go from rule to TI.
Again, I managed to get a result by using this calculation in the TI. See here the part for the 1st rule part:
vSource='ALO';
vDiff=cellgetn('GPC_1','OTH', 'PS', BUSINESS_UNIT, V4, PERIODE, Business_Typ, DEPT, ACCT, PROD, '9999999999') - cellgetn('GPC_1','ALL_CUST_TYP', 'HEX', BUSINESS_UNIT, V4, PERIODE, Business_Typ, DEPT, ACCT, PROD, 'ALL_CUSTOMER');
vSpread=cellgetn('GPC_1',CUST_TYP, 'NR', BUSINESS_UNIT, V4, PERIODE, Business_Typ, DEPT, 'STAFFING / INTERIM REVENUE', 'ALL_PROD', CUST) / cellgetn('GPC_1','ALL_CUST_TYP', 'NR', BUSINESS_UNIT, V4, PERIODE, Business_Typ, DEPT, 'STAFFING / INTERIM REVENUE', 'ALL_PROD', 'ALL_CUSTOMER') ;
vValue=vDiff * vSpread;
CellPutN(vValue,'GPC_1',CUST_TYP,vSource,BUSINESS_UNIT,V4,PERIODE,BUSINESS_TYP,DEPT,ACCT,PROD,CUST);
When I am running this as a test on a close range of test data all works fine, when I am running this on a bigger range, the TI runs forever. I am guessing I need to build in some looping, so that the code goes thru the data and not pulls the data in a view and then working up the calculations, but I am not sure and not really familiar with building a code which loops thru the code.
Any helps you guys can give me on this, either rule or TI, is greatly appreciated.
If my details are confusing and you need further explanations, please advise
Regards Manfred