Hi All,
Here is the scenario we are facing the issues, we have to read each record by record and calculate the sub total and main total also should remain same even after re-allocation at discrete level.
Measure used is a Volume ,it cannot be a decimal.
we have some pre-populated volumes from source for PNO12 with sub -totals as 45, 9 and 27 respectively.
Now user ,will re-allocate the volumes from existing customer category to a new categories like
10A = 30 , 20A = 30 and 71A = 21, after the allocation sub totals should remain same at CC and PNO12
like 45 at 224 H1 G3 0 D 1 19 and so on.

Please correct this below code and suggest if any idea and it should be dynamic.
CONFIG.HIERARCHY.INCLUDE_MEMBERS_NOT_IN_HIERARCHY =[d/DIM_BPACCT]
CONFIG.READ_CALCULATED_MEMBER_VALUES =ON
MEMBERSET [d/Measures] ="ZVOLUME"
MEMBERSET [d/DIM_DATASRC]="CALCULATE"
MEMBERSET [d/DIM_MODELYR]="#"
MEMBERSET [d/DIM_FACTORY]="#"
MEMBERSET [d/Date] = [d/Version].[p/Cutoff_Date] TO [d/Version].[p/Enddate]
MEMBERSET [d/DIM_MKT] = BASEMEMBER([d/DIM_MKT] , %UNMarket%)
MEMBERSET [d/DIM_PNO3]= BASEMEMBER([d/DIM_PNO3] ,%PNO3% )
MEMBERSET [d/DIM_VERSION]=%PlanningVersion%
//MEMBERSET [d/DIM_PNO12] =("224 H1 G3 0 D 1 19", "224 H4 G3 0 D 1 19")
VARIABLEMEMBER #Total_Amount OF [d/Measures]
VARIABLEMEMBER #STORE6520_COPY OF [d/Measures]
VARIABLEMEMBER #Total6520_INPUT OF [d/Measures]
VARIABLEMEMBER #CCPercentage OF [d/Measures]
VARIABLEMEMBER #Store_6520INPUT OF [d/Measures]
VARIABLEMEMBER #Total_6520 OF [d/DIM_BPACCT]
VARIABLEMEMBER #Subtotal_of_Each_CC OF [d/DIM_PNO12]
VARIABLEMEMBER #Difference_in_CC OF [d/Measures]
VARIABLEMEMBER #PNO12SUBTOTAL_POSTALLOCATION OF [d/DIM_CUSTCAT]
VARIABLEMEMBER #TEST1 OF [d/Measures]
VARIABLEMEMBER #TEST2 OF [d/Measures]
VARIABLEMEMBER #TEST3 OF [d/Measures]
VARIABLEMEMBER #TEST4 OF [d/Measures]
VARIABLEMEMBER #Store OF [d/Measures]
VARIABLEMEMBER #Store2 OF [d/Measures]
VARIABLEMEMBER #TOTALOFPREVIOUS OF [d/Measures]
VARIABLEMEMBER #Account OF [d/DIM_BPACCT]
VARIABLEMEMBER #CC OF [d/DIM_CUSTCAT]
VARIABLEMEMBER #SubTotatofPNO12 OF [d/DIM_CUSTCAT]
VARIABLEMEMBER #CCtotal OF [d/DIM_CUSTCAT]
VARIABLEMEMBER #FINDDIFF OF [d/Measures]
VARIABLEMEMBER #VOLSTORE OF [d/Measures]
VARIABLEMEMBER #FINALSTORE OF [d/Measures]
INTEGER @CurrentCount
INTEGER @GETTOTAL
//Simple copy from 6520_COPY to store it in Variable member
DATA( [d/DIM_BPACCT]="6520_COPY", [d/Measures]=#STORE6520_COPY ) = RESULTLOOKUP([d/DIM_BPACCT]="6520_COPY", [d/Measures]="ZVOLUME")
//Store User Input values 6520_INPUT Example: 10A-27 and 20A-27
DATA([d/Measures]=#Store_6520INPUT, [d/DIM_BPACCT]="6520_INPUT" ) =RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_INPUT")
//Subtotal of Each PNO12 Example: 45 , 9 (Account: 6520_COPY)
DATA( [d/DIM_BPACCT]="6520_COPY", [d/Measures]=#Total_Amount, [d/DIM_CUSTCAT]=#SubTotatofPNO12 ) = RESULTLOOKUP([d/DIM_BPACCT]="6520_COPY", [d/Measures]="ZVOLUME")
//Store user inputted values example, 27+27 = 54 will get here (Account: 6520_INPUT)
DATA([d/Measures]=#Total6520_INPUT, [d/DIM_CUSTCAT]=#CCtotal,[d/DIM_BPACCT]="6520_INPUT", [d/DIM_ENGINE]="#",[d/DIM_FACTORY]="#", [d/DIM_INDICATOR]="#", [d/DIM_MODELYR]="#", [d/DIM_PNO12]="#", [d/DIM_PRD_ID]="#", [d/DIM_SV]="#" )
= RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_INPUT", [d/DIM_ENGINE]="#",[d/DIM_FACTORY]="#", [d/DIM_INDICATOR]="#", [d/DIM_MODELYR]="#", [d/DIM_PNO12]="#", [d/DIM_PRD_ID]="#", [d/DIM_SV]="#")
//Find the Percentage for user Inputted values Example: 27/54, 27/54 (Account: 6520_INPUT)
DATA([d/Measures]=#CCPercentage,[d/DIM_BPACCT]="6520_INPUT", [d/DIM_ENGINE]="#",[d/DIM_FACTORY]="#", [d/DIM_INDICATOR]="#", [d/DIM_MODELYR]="#", [d/DIM_PNO12]="#", [d/DIM_PRD_ID]="#", [d/DIM_SV]="#" ) =( RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_INPUT", [d/DIM_ENGINE]="#",[d/DIM_FACTORY]="#", [d/DIM_INDICATOR]="#", [d/DIM_MODELYR]="#", [d/DIM_PNO12]="#", [d/DIM_PRD_ID]="#", [d/DIM_SV]="#")/RESULTLOOKUP([d/Measures]=#Total6520_INPUT, [d/DIM_CUSTCAT]=#CCtotal,[d/DIM_BPACCT]="6520_INPUT", [d/DIM_ENGINE]="#",[d/DIM_FACTORY]="#", [d/DIM_INDICATOR]="#", [d/DIM_MODELYR]="#", [d/DIM_PNO12]="#", [d/DIM_PRD_ID]="#", [d/DIM_SV]="#" ))
//Multiply Percentage with PNO12 Subtotal Example: 0.5*45, 0.5*45 AND 0.5*9 , 0.5*9 (Account: 6520_COPY)//
//Volume will be 22, 22 AND 4, 4 due to integer measure
DATA([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#") = RESULTLOOKUP([d/Measures]=#CCPercentage,[d/DIM_BPACCT]="6520_INPUT", [d/DIM_ENGINE]="#",[d/DIM_FACTORY]="#", [d/DIM_INDICATOR]="#", [d/DIM_MODELYR]="#", [d/DIM_PNO12]="#", [d/DIM_PRD_ID]="#", [d/DIM_SV]="#" )*RESULTLOOKUP([d/DIM_BPACCT]="6520_COPY", [d/Measures]=#Total_Amount, [d/DIM_CUSTCAT]=#SubTotatofPNO12)
//Store the same calculation into variable member to get the decimal values (Original allocated values,Example: 22.5, 22.5 AND 4.5, 4.5)
DATA([d/Measures]=#VOLSTORE, [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#") = RESULTLOOKUP([d/Measures]=#CCPercentage,[d/DIM_BPACCT]="6520_INPUT", [d/DIM_ENGINE]="#",[d/DIM_FACTORY]="#", [d/DIM_INDICATOR]="#", [d/DIM_MODELYR]="#", [d/DIM_PNO12]="#", [d/DIM_PRD_ID]="#", [d/DIM_SV]="#" )*RESULTLOOKUP([d/DIM_BPACCT]="6520_COPY", [d/Measures]=#Total_Amount, [d/DIM_CUSTCAT]=#SubTotatofPNO12)
//PNO12 Subtotal after allocation Example: After allocation 22+22-->44 and 4+4-->8
DATA([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_CUSTCAT]=#PNO12SUBTOTAL_POSTALLOCATION) =RESULTLOOKUP([d/DIM_BPACCT]="6520_COPY", [d/Measures]="ZVOLUME",[d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#")
//Each CC subtotal after allocation, Example : 10A=22+4->26 , 20A=22+4-->26
DATA([d/Measures]="ZVOLUME", [d/DIM_PNO12]=#Subtotal_of_Each_CC, [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#") = RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#")
//Find difference between Pre Allocated and Post Allocated... 10A(PreAlloc) - 10A(PostAlloc)
DATA([d/Measures]=#Difference_in_CC, [d/DIM_BPACCT]="6520_COPY" , [d/DIM_PNO12]="#", [d/DIM_MODELYR]="#", [d/DIM_FACTORY]="#") = RESULTLOOKUP([d/Measures]=#Store_6520INPUT, [d/DIM_BPACCT]="6520_INPUT",[d/DIM_PNO12]="#", [d/DIM_MODELYR]="#",[d/DIM_FACTORY]="#")- RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_PNO12]=#Subtotal_of_Each_CC, [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#")
//1st PNO12
IF [d/DIM_PNO12]!="#" THEN
FOREACH.BOOKED [d/DIM_PNO12]
IF RESULTLOOKUP( [d/DIM_BPACCT]="6520_COPY", [d/Measures]=#Total_Amount, [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_CUSTCAT]=#SubTotatofPNO12)!= RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_CUSTCAT]=#PNO12SUBTOTAL_POSTALLOCATION) THEN
IF [d/DIM_CUSTCAT]=%CustomerCategory% THEN
IF RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_PNO12]=#Subtotal_of_Each_CC, [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#")!= RESULTLOOKUP([d/Measures]=#Store_6520INPUT, [d/DIM_BPACCT]="6520_INPUT",[d/DIM_PNO12]="#", [d/DIM_MODELYR]="#",[d/DIM_FACTORY]="#") THEN
DATA([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#")= RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#")+ RESULTLOOKUP([d/Measures]=#Difference_in_CC, [d/DIM_BPACCT]="6520_COPY" , [d/DIM_PNO12]="#", [d/DIM_MODELYR]="#", [d/DIM_FACTORY]="#" )
ENDIF
ENDIF
ENDIF
ENDIF
ENDFOR
ENDIF
//2nd PNO12
DATA([d/Measures]=#TEST1, [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_PNO12]="#")= RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_CUSTCAT]=[d/DIM_CUSTCAT].[p/ID])
DATA([d/Measures]=#TEST2, [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_CUSTCAT]=#CC)= RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_CUSTCAT]=[d/DIM_CUSTCAT].[p/ID])
IF [d/DIM_PNO12]!="#" THEN
FOREACH.BOOKED [d/DIM_PNO12]
//FOREACH.BOOKED [d/DIM_CUSTCAT]
IF [d/DIM_CUSTCAT]=%CustomerCategory% THEN
IF RESULTLOOKUP( [d/DIM_BPACCT]="6520_COPY", [d/Measures]=#Total_Amount, [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#",[d/DIM_CUSTCAT]=#SubTotatofPNO12)!= RESULTLOOKUP([d/Measures]=#TEST2, [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_CUSTCAT]=#CC) THEN
IF RESULTLOOKUP([d/Measures]=#TEST1, [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_PNO12]="#", [d/DIM_CUSTCAT]=[d/DIM_CUSTCAT].[p/ID])
!= RESULTLOOKUP([d/Measures]=#Store_6520INPUT, [d/DIM_BPACCT]="6520_INPUT", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_PNO12]="#",[d/DIM_CUSTCAT]=[d/DIM_CUSTCAT].[p/ID]) THEN
DATA([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#")= RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#")+ RESULTLOOKUP([d/Measures]=#Difference_in_CC, [d/DIM_BPACCT]="6520_COPY" , [d/DIM_PNO12]="#", [d/DIM_MODELYR]="#", [d/DIM_FACTORY]="#" )
ENDIF
ENDIF
ENDIF
ENDIF
//ENDFOR
ENDFOR
ENDIF
//3rd PNO12
DATA([d/Measures]=#TEST3, [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_PNO12]="#")= RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_CUSTCAT]=[d/DIM_CUSTCAT].[p/ID])
DATA([d/Measures]=#TEST4, [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_CUSTCAT]=#CC)= RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_CUSTCAT]=[d/DIM_CUSTCAT].[p/ID])
IF [d/DIM_PNO12]!="#" THEN
FOREACH.BOOKED [d/DIM_PNO12]
//FOREACH.BOOKED [d/DIM_CUSTCAT]
IF [d/DIM_CUSTCAT]=%CustomerCategory% THEN
IF RESULTLOOKUP( [d/DIM_BPACCT]="6520_COPY", [d/Measures]=#Total_Amount, [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#",[d/DIM_CUSTCAT]=#SubTotatofPNO12)!= RESULTLOOKUP([d/Measures]=#TEST4, [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_CUSTCAT]=#CC) THEN
IF RESULTLOOKUP([d/Measures]=#TEST3, [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_PNO12]="#", [d/DIM_CUSTCAT]=[d/DIM_CUSTCAT].[p/ID])
!= RESULTLOOKUP([d/Measures]=#Store_6520INPUT, [d/DIM_BPACCT]="6520_INPUT", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#", [d/DIM_PNO12]="#",[d/DIM_CUSTCAT]=[d/DIM_CUSTCAT].[p/ID]) THEN
DATA([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#")= RESULTLOOKUP([d/Measures]="ZVOLUME", [d/DIM_BPACCT]="6520_COPY", [d/DIM_FACTORY]="#", [d/DIM_MODELYR]="#")+ RESULTLOOKUP([d/Measures]=#Difference_in_CC, [d/DIM_BPACCT]="6520_COPY" , [d/DIM_PNO12]="#", [d/DIM_MODELYR]="#", [d/DIM_FACTORY]="#" )
ENDIF
ENDIF
ENDIF
ENDIF
ENDFOR
//ENDFOR
ENDIF
Data action-advanced formula.txt
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.