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

Script logic calcuation

Former Member
0 Likes
356

Hi,

I want to calculate PD3900X of 2015.01= PD3900X of 2014.Y+ P11000X of 2015.01 -  CFH_CG1100 of 2015.01 - ZA1200X of 2015.01 + P90001 of 2015.01

All the above are accounts. THis calculation is to be triggered by a data manager package.

I have written the below code - cannot copy paste the code. Hence attached the code in txt format.

Please note that all the nodes are leaf nodes except CFH_CG1100 node. CFH_CG1100 is a parent node which has a set of children under it.

My first set of code,  which is first when loop executes fine.

The part of code which I have written when PD3900X of 2014.Y is blank - is giving problem. It is calculating multiple times. The answer I am getting is 4 times the expected answer.

I understand that when the "when loop" closes, the answers should be over written. But they are not!! Any suggestions are welcomed.

Thanks,

Swetha

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member186338
Active Contributor
0 Likes

Sorry, but the code is not attached!

Why you can't copy paste??? Try another browser!

Former Member
0 Likes

code attached

former_member186338
Active Contributor
0 Likes

The code is strange and has to be rewritten...

Extra question - what do you mean by this undefined variable %RETYEAR%

Please read

Former Member
0 Likes

%RETYEAR% is a variable which will pick the year from the parameter passed. For eg - if we are passing 2015.Y in data manager package, then using below select statement, it picks up 2015 as its value.

*SELECT(%RETYEAR%, [YEAR], CHEM_TIME, [ID] = 2015.Y

The select statement has got missed in the code I have attached. Sorry!

former_member186338
Active Contributor
0 Likes

Look on this code:

*XDIM_MEMBERSET CHEM_TIME = 2014.Y,2015.01

*WHEN CHEM_TIME

*IS 2014.Y

  *WHEN CHEM_LINE

  *IS PD3900X

    *REC(EXPRESSION=%VALUE%,CHEM_TIME=2015.01)

  *ENDWHEN

*IS 2015.01

  *WHEN CHEM_LINE

  *IS P11000X

    *REC(EXPRESSION=%VALUE%,CHEM_LINE=PD3900X)

  *IS BAS(CFH_CG1100)

    *REC(EXPRESSION=-%VALUE%,CHEM_LINE=PD3900X)

  *IS ZA1200X

    *REC(EXPRESSION=-%VALUE%,CHEM_LINE=PD3900X)

  *IS P90001

    *REC(EXPRESSION=%VALUE%,CHEM_LINE=PD3900X)

  *ENDWHEN

*ENDWHEN

former_member186338
Active Contributor
0 Likes

P.S. Scope for CHEM_LINE can be also added:

*XDIM_MEMBERSET CHEM_LINE=BAS(CFH_CG1100),PD3900X,P11000X,ZA1200X,P90001

Former Member
0 Likes

THanks Vadim. I have rewritten the code as below. *FOR %TIME3% = %MTH% *WHEN CHEM_TIME *IS %TIME3%   *WHEN CHEM_LINE   *IS PD3900X   *REC(EXPRESSION=%VALUE%,CHEM_TIME=TMVL(1,%TIME3%))   *ENDWHEN *IS TMVL(1,%TIME3%)   *WHEN CHEM_LINE   *IS P11000X     *REC(EXPRESSION=%VALUE%,CHEM_LINE=PD3900X)   *IS BAS(CFH_CG1100)     *REC(EXPRESSION=-%VALUE%,CHEM_LINE=PD3900X)   *IS ZA1200X     *REC(EXPRESSION=-%VALUE%,CHEM_LINE=PD3900X)   *IS P90001     *REC(EXPRESSION=%VALUE%,CHEM_LINE=PD3900X)   *ENDWHEN *ENDWHEN *NEXT The above loop runs from Jan 2015 to Dec 2015. But I think the calculation is not happening as expeted. I wanted  PD3900X of 2015.01= PD3900X of 2014.Y+ P11000X of 2015.01 -  CFH_CG1100 of 2015.01 - ZA1200X of 2015.01 + P90001 of 2015.01 But, the calculation is happening as PD3900X of 2015.01= PD3900X of 2014.Y+ P11000X of 2014.Y -  CFH_CG1100 of 2014.Y - ZA1200X of 2014.Y + P90001 of 2014.Y  

former_member186338
Active Contributor
0 Likes

The code is unreadable!

Former Member
0 Likes

added the attachment.

former_member186338
Active Contributor
0 Likes

Looks it's a waste of time...

You do not provide full code!

Please answer the following question:

What do you want the user to select?

Then based on the user selection explain the required script logic! For all months!

P.S. And the logic of TMVL in you code is not in line with your requirements!

Former Member
0 Likes

I have attached the full code, expected result and the log what I am getting now when I executed the data manger package.

former_member186338
Active Contributor
0 Likes

Sorry, let's start from the very beginning! I am unable to understand the calculation logic you want to achieve!

What do you want the user to select?

Then based on the user selection explain the required script logic! For all months!

Former Member
0 Likes

Vadim, First of all, I want to thank you a lot for your time and all the efforts.

Basically I am trying for carry forward of numbers for the whole year based on below steps:

  1. PD3900X of 2015.01 = PD3900X of 2014.Y + P11000X of 2015.01 - CFH_CG1100 of 2015.01 - ZA1200X of 2015.01  + P90001 of 2015.01
  2. PD3900X of 2015.02 = PD3900X of 2015.01 + P11000X of 2015.02 -CFH_CG1100 of 2015.02 - ZA1200X of 2015.02 + P90001 of 2015.02
  3. similarly for march .....till . Dec

In the data manager package, user selects 2015.Y in case of above example.

Let me know if case you need more information

former_member186338
Active Contributor
0 Likes

OK, now it's more or less clear

I also need a screenshot of your time dimension with TIMEID visible and PARENTH1 for normal months and for 2014.Y

Former Member
0 Likes
former_member186338
Active Contributor
0 Likes

You have incorrect TIME dimension setup!

XXXX.Y members has to be inside 3 level hierarchy.

Without it you will have a lot of issues!

Former Member
0 Likes

Vadim, I don't think I can change this now. This is an existing dimension and changing of this will require lot of approvals and etc etc.

I need to work with this set up itself.

former_member186338
Active Contributor
0 Likes

Currently you have the system that will produce a lot of errors due to incorrect time dimension. You can't work with "this set up itself" Hope you understand me!

former_member186338
Active Contributor
0 Likes

Sample code:

*XDIM_MEMBERSET CHEM_TIME AS %T_VAR1% = 2015.01

*XDIM_MEMBERSET CHEM_TIME AS %TIME1% = 2014.Y         

*XDIM_MEMBERSET CHEM_TIME AS %MTH% = 2015.01, 2015.02, 2015.03, 2015.04, 2015.05, 2015.06, 2015.07, 2015.08, 2015.09, 2015.10, 2015.11

//The BELOW code is to copy from 2014.Y TO 2015.01

*XDIM_MEMBERSET CHEM_TIME = %TIME1%,%T_VAR1%

*WHEN CHEM_TIME

*IS %TIME1% //2014.Y

*WHEN CHEM_LINE

*IS PD3900X

*REC(EXPRESSION=%VALUE%,CHEM_TIME=%T_VAR1%)

*ENDWHEN

*IS %T_VAR1% //2015.01

*WHEN CHEM_LINE

*IS P11000X

*REC(EXPRESSION =%VALUE%, CHEM_LINE=PD3900X)

*IS BAS(CFH_CG1100)

*REC(EXPRESSION=-%VALUE%,CHEM_LINE=PD3900X)

*IS ZA1200X

*REC(EXPRESSION=-%VALUE%,CHEM_LINE=PD3900X)

*IS P90001

*REC(EXPRESSION=%VALUE%,CHEM_LINE=PD3900X)

*ENDWHEN

*ENDWHEN

//The BELOW code is to copy from 2015.01 TO 2015.02, 2015.02 TO 2015.03....................2015.11 TO 2015.12

*FOR %TIME3% = %MTH% //2015.01-2015.11!!!

*XDIM_MEMBERSET CHEM_TIME = %TIME3%,TMVL(1,%TIME3%)

*WHEN CHEM_TIME

*IS %TIME3%

  *WHEN CHEM_LINE

  *IS PD3900X

  *REC(EXPRESSION=%VALUE%,CHEM_TIME=TMVL(1,%TIME3%))

  *ENDWHEN

*IS TMVL(1,%TIME3%)

  *WHEN CHEM_LINE

  *IS P11000X

    *REC(EXPRESSION=%VALUE%,CHEM_LINE=PD3900X)

  *IS BAS(CFH_CG1100)

    *REC(EXPRESSION=-%VALUE%,CHEM_LINE=PD3900X)

  *IS ZA1200X

    *REC(EXPRESSION=-%VALUE%,CHEM_LINE=PD3900X)

  *IS P90001

    *REC(EXPRESSION=%VALUE%,CHEM_LINE=PD3900X)

  *ENDWHEN

*ENDWHEN

*NEXT