cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

RUNALLOCATION Issue

0 Likes
4,061

Dear BPC Experts,

We are working on creating a logic script that allocates budget total figures of a year among months using actual figures of 3 years earlier. (Ex. Jan. 2017 budget data should be calculated using actual data of Jan.2016,Jan.2015 & Jan.2014 / Total actual Data in 2016,2015 & 2014

We have created the attached logic script which has 2 problems:

1. Previous year can not be determined dynamically as TMVL is generating incorrect results.

2. Allocation can be done using historical data of 1 year earlier only and not 3 years.

Please advice, How we can handle those two problems.

Thanks and Best Regards

Sara Kadry

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member186338
Active Contributor
0 Likes

Please, prepare your question in line with

The provided script is incorrect!

P.S. "Ex. Jan. 2017 budget data should be calculated using actual data of Jan.2016,Jan.2015 & Jan.2014 / Total actual Data in 2016,2015 & 2014" - not clear! Show Excel screenshot of the required calculations.

0 Likes

Dear Vadim,

Thanks for letting me know the rules to ask a question related to script logic as it is my first time to post any question in the community so I wasn't aware of the existence of such rules.

On the other side telling me exactly what is incorrect in my logic will be much more helpful than just saying that it's incorrect specially that I already mentioned that the script is generating correct results and it has only the 2 problems mentioned above.

As requested below excel screenshot demonstrates the required calculation:

former_member186338
Active Contributor
0 Likes

I have posted the rules to save my time asking all the questions described in the rules

For example: "6. Provide FULL script that is not working (showing only part of the script without some previous scope changes can lead to misunderstanding). It's better to use some fixed character width font like Courier New to format the code text."

You posted the screenshot! Do you want me to retype your script from the screenshot?

P.S. 7. For DM scripts define what user will select/enter for DM prompts.

You have variables in your script and I have no idea about the values passed!

Etc...

former_member186338
Active Contributor
0 Likes

P.P.S.

"the script is generating correct results"

"Allocation can be done using historical data of 1 year earlier only and not 3 years."

don't you think that it's looking contradictorily?

0 Likes

1. Our BPC Version & Support Package:

2.The K2 Calculation engine used is JAVESCRIPT

3.Sales Model consists of 8 dimensions :

     Category

     Channel (User Defined)

     Input Currency    

     Location (User Defined)

     Product (User Defined)

     Profit Center (Entity)

     Time

     Vehicles Values(Account)

4.The Script is to be Launched by DM Package

5.Calculation Logic: Already Described in my 1st message

6. The script is shown below:

//TOTAL in channel and location are base level members containing the un-allocated figures

//ALL is a parent member grouping all sales channels (Retail, Wholesales...etc.)

//ALLHER is a parent member grouping all products of a certain type

*XDIM_MEMBERSET PRODUCT=BAS(ALLHER)

*SELECT(%TIMES%,[MONTHNUM],TIME,[YEAR]=$INPUT_YEAR$

*FOR %TIM%=%TIMES%

*RUNALLOCATION

*FACTOR=USING/TOTAL

*DIM CATEGORY WHAT=BUDGET; WHERE=BUDGET; USING=ACTUAL; TOTAL=<<<

*DIM LOCATION WHAT=TOTAL ;WHERE=<<<; USING=BAS(ALL);TOTAL=<<<

*DIM CHANNEL WHAT=TOTAL;WHERE=BAS(ALL);USING=<<<;TOTAL=<<<

*DIM TIME WHAT=$INPUT_YEAR$ ; WHERE=[YEAR]=$INPUT_YEAR AND [MONTHNUM]=%TIM% ; USING=[YEAR]="2016" AND [MONTHNUM]=%TIM% ; TOTAL=[YEAR]="2016"

*ENDALLOCATION

*NEXT

7.The user will input the target planning year (2017)

----------------------------------------------------------------------

What I mean by generating Correct results is that it generates correct results using 1 year not 3 years which means it's a correct logic script(From the technical point of view) but not satisfying all our requirements

former_member186338
Active Contributor
0 Likes

Not clear:

*DIM TIME WHAT=$INPUT_YEAR$;...

means:

*DIM TIME WHAT=2017;...

What is 2017? has to be a base member!

Show the structure of your time dimension...

0 Likes

2017 is a base level member and below is the structure/members of Time dimension:

former_member186338
Active Contributor
0 Likes

Sorry, but you have incorrect structure of TIME dimension. All base members has to be in the 3 level structure (year-quarter-month). Like here 2015.INP is a base member for year input!

former_member186338
Active Contributor
0 Likes

And sorry, can you copy/paste you real script?

I see number of typing errors in the script you post here:

*SELECT(%TIMES%,[MONTHNUM],TIME,[YEAR]=$INPUT_YEAR$     -")" missing!

*DIM TIME WHAT=$INPUT_YEAR$ ; WHERE=[YEAR]=$INPUT_YEAR AND...    = "$" missing!

...

P.S. Working with script logic you have to be precisely accurate

0 Likes

We created a dummy base level member 2017 to carry the total planned value and below is the complete time structure:

Below is the pasted script:

*XDIM_MEMBERSET PRODUCT = BAS(ALLHER)

*SELECT(%TIMES%,[MONTHNUM],TIME,[YEAR]=$INPUT_YEAR$)

*FOR %TIM% = %TIMES%

*RUNALLOCATION

*FACTOR = USING/TOTAL

*DIM CATEGORY WHAT=Budget; WHERE=Budget    ; USING=Actual    ; TOTAL = <<<

*DIM LOCATION WHAT=TOTAL  ; WHERE=<<<

*DIM CHANNEL WHAT=TOTAL  ; WHERE= bas(ALL)  ; USING=<<

*DIM TIME WHAT=$INPUT_YEAR$  ; WHERE=[YEAR]="$INPUT_YEAR$" AND [MONTHNUM] = "%TIM%"  ; USING= [YEAR]="2016" AND [MONTHNUM] = "%TIM%"  ; TOTAL = [YEAR]="2016"

*ENDALLOCATION

*NEXT

former_member186338
Active Contributor
0 Likes

"We created a dummy base level member 2017 to carry the total planned value and below is the complete time structure" - incorrect! Look on my time dimension structure sample!

You have to create also dummy quarter and dummy year!

0 Likes

Dear Vadim,

The values are already available on 2017 level, we can discuss the Time dimension structure later but now I need to know how to allocate the values using historical data of 3 years

former_member186338
Active Contributor
0 Likes

Sorry, but time dimension without 3 level will result in a lot of errors! You have to correct it before doing anything else...

0 Likes

What shall I do in the script after correcting the part you are talking about??

former_member186338
Active Contributor
0 Likes

First correct and show your time dimension! Look on TIMEID property...

former_member186338
Active Contributor
0 Likes

Just to check - do you want to calculate something like this:

*RUNALLOCATION

*FACTOR=USING/TOTAL

*DIM TIME WHAT=2015; WHERE=2015.01; USING=2014.01,2013.01,2012.01; TOTAL=[YEAR]="2014" AND [YEAR]="2013" AND [YEAR]="2012"

*ENDALLOCATION

?

0 Likes

That is exactly what I want to do

Also I have updated the Time dimension as shown below:

former_member186338
Active Contributor
0 Likes

You have to also set Level property of members like 2017 to MONTH.

If you setup TIMEID property like:

2017 10170100

2016 10160100

...

Then TMVL(-1,2017) will be 2016 etc...

0 Likes

I've performed all the updates in the Time Dimension but the problem from the early beginning was that TMVL generates incorrect results when being used in RUNALLOCATION as shown below and as mentioned in my original message:

"Extra Comma is added to the member value"

Former Member
0 Likes

Hi Sara,

What would you expect TMVL(-1, 2017) to be?

To calculate this BPC will take TIMEID of 2017 (10170100), find the previous one and take ID of that member. Since you don't show what is TIMEID of 2016 it's hard to tell if result is wrong or correct.

Regards,

Gersh

0 Likes

Hi Gersh,

2016 TIMID is 10160100.

Regards

Sara

former_member186338
Active Contributor
0 Likes

There is a way to get a previous year from the current year without TMVL:

First - create YINP property (1 char) in TIME dimension and fill it with Y for Year input base members (2006,2007,2008,2009...)

Then look on the following script to get a previous year in the variable %PREVY%:

//$INPUT_YEAR$=2009

*SELECT(%TID%,[TIMEID],TIME,[ID]=$INPUT_YEAR$)

//%TID%=10090100

*SELECT(%TIDSBEFORE%,[TIMEID],TIME,[TIMEID]<%TID% AND [YINP]=Y)

//%TIDSBEFORE%=10060100,10070100,10080100 - 2006,2007,2008

*SELECT(%TSAFTERINCL%,[ID],TIME,[TIMEID]>=%TIDSBEFORE% AND [YINP]=Y)

//%TSAFTERINCL%=2008,2009,2010...

*SELECT(%PREVY%,[ID],TIME,[TIMEID]=%TIDSBEFORE% AND [ID]=%TSAFTERINCL%)

//%PREVY%=2008

*XDIM_MEMBERSET TIME=%PREVY%

Same calculations can be done to calculate %PREVPREVY% and %PREVPREVPREVY% ...

Then

*RUNALLOCATION

*FACTOR=USING/TOTAL

*DIM TIME WHAT=$INPUT_YEAR$; WHERE=$INPUT_YEAR$.%MNTH%; USING=%PREVY%.%MNTH%,%PREVPREVY%.%MNTH%,%PREVPREVPREVY%.%MNTH%; TOTAL=[YEAR]="%PREVY%" AND [YEAR]="%PREVPREVY%" AND [YEAR]="%PREVPREVPREVY%" AND [YINP]=""

*ENDALLOCATION

former_member186338
Active Contributor
0 Likes

P.S.:

*SELECT(%TID1%,[TIMEID],TIME,[ID]=%PREVY%)

*SELECT(%TIDSBEFORE1%,[TIMEID],TIME,[TIMEID]<%TID1% AND [YINP]=Y)

*SELECT(%TSAFTERINCL1%,[ID],TIME,[TIMEID]>=%TIDSBEFORE1% AND [YINP]=Y)

*SELECT(%PREVPREVY%,[ID],TIME,[TIMEID]=%TIDSBEFORE1% AND [ID]=%TSAFTERINCL1%)

*SELECT(%TID2%,[TIMEID],TIME,[ID]=%PREVPREVY%)

*SELECT(%TIDSBEFORE2%,[TIMEID],TIME,[TIMEID]<%TID2% AND [YINP]=Y)

*SELECT(%TSAFTERINCL2%,[ID],TIME,[TIMEID]>=%TIDSBEFORE2% AND [YINP]=Y)

*SELECT(%PREVPREVPREVY%,[ID],TIME,[TIMEID]=%TIDSBEFORE2% AND [ID]=%TSAFTERINCL2%)

former_member186338
Active Contributor
0 Likes

Just tested the full script and got absolutely correct figures in the report:

*SELECT(%TID%,[TIMEID],PERIODS,[ID]=$INPUT_YEAR$)

*SELECT(%TIDSBEFORE%,[TIMEID],PERIODS,[TIMEID]<%TID% AND [YINP]=Y)

*SELECT(%TSAFTERINCL%,[ID],PERIODS,[TIMEID]>=%TIDSBEFORE% AND [YINP]=Y)

*SELECT(%PREVY%,[ID],PERIODS,[TIMEID]=%TIDSBEFORE% AND [ID]=%TSAFTERINCL%)

*SELECT(%TID1%,[TIMEID],PERIODS,[ID]=%PREVY%)

*SELECT(%TIDSBEFORE1%,[TIMEID],PERIODS,[TIMEID]<%TID1% AND [YINP]=Y)

*SELECT(%TSAFTERINCL1%,[ID],PERIODS,[TIMEID]>=%TIDSBEFORE1% AND [YINP]=Y)

*SELECT(%PREVPREVY%,[ID],PERIODS,[TIMEID]=%TIDSBEFORE1% AND [ID]=%TSAFTERINCL1%)

*SELECT(%TID2%,[TIMEID],PERIODS,[ID]=%PREVPREVY%)

*SELECT(%TIDSBEFORE2%,[TIMEID],PERIODS,[TIMEID]<%TID2% AND [YINP]=Y)

*SELECT(%TSAFTERINCL2%,[ID],PERIODS,[TIMEID]>=%TIDSBEFORE2% AND [YINP]=Y)

*SELECT(%PREVPREVPREVY%,[ID],PERIODS,[TIMEID]=%TIDSBEFORE2% AND [ID]=%TSAFTERINCL2%)

*FOR %MNTH%=JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC

*XDIM_MEMBERSET TITLES=1110

*XDIM_MEMBERSET BE=BE1000

*XDIM_MEMBERSET CORPDIR=DIRECT

*XDIM_MEMBERSET INACCT=106

*XDIM_MEMBERSET PLANTYPE=BUDGET

*RUNALLOCATION

*FACTOR=USING/TOTAL

*DIM PERIODS WHAT=$INPUT_YEAR$; WHERE=$INPUT_YEAR$.%MNTH%; USING=%PREVY%.%MNTH%,%PREVPREVY%.%MNTH%,%PREVPREVPREVY%.%MNTH%; TOTAL=[YEAR]="%PREVY%" AND [YEAR]="%PREVPREVY%" AND [YEAR]="%PREVPREVPREVY%"  AND [YINP]=""

*ENDALLOCATION

*NEXT

P.S. My TIME dimension is named PERIODS

Former Member
0 Likes

Can you sort your Time Dimension on TIMEID property? If you don't have anything between 10160100 and 10170100 then TMVL(-1, 2017) = 2016

So, what did you expect it o be?

-Gersh

former_member186338
Active Contributor
0 Likes

Hi Gersh,

For this particular requirements TMVL is not very useful. I have presented the code to get previous year and store it in the variable without TMVL.

Vadim

0 Likes

Dear Vadim,

Thanks a lot for your great support.

The script worked Perfectly.

Thanks and Regards

Sara