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

Question how to count in script Logic

former_member182305
Active Participant
0 Kudos
351

Hello experts,

I am trying to figure out how to count in Script Logic.

I wasreading the next post:

How to use a Count in ScriptLogic | SCN

I use the syntaxis as is described in the post:

*SELECT (%NMEMBERS%, count(),PERIODO, ID=%PERIODO_SET%)

Periodo is my dimension and %PERIODO_SET% is the selection that the user use when running the Data Manager to run this SL.

I got the error "INVALID ATTRIBUTE NAME (count() in Dimension (PERIODO)

What is wrong in the sentence?

Is there another way to count the number of months selected by user in the %PERIODO_SET%?

Thanks for the posts.

Regards

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Kudos

"count the number of months selected by user in the %PERIODO_SET%" - sorry, but what for???

And for sure select doesn't support syntax with count

P.S. And never try to use solutions proposed for BPC MS in BPC NW

former_member182305
Active Participant
0 Kudos

I need to know the number of months selected by user. This is because In the script logic I have, for %T%= %PERIODO_SET% has to do a a calculation, after %PERIODO_SET% it has to be another different calc.

For instance,

The user selects Jan to Aug, (this is Calculation A)

from Aug to Dec, I have to do another Calculation (B).

Is there a way to konw how many months did the user selected or the last element of the selection? that way I think TMVL could be used.

Thanks for the answers

Regards.

former_member186338
Active Contributor
0 Kudos

What if user select Jan to Dec

Please explain the calculation logic assuming that the user can select any months!

P.S. TMVL will not help

former_member186338
Active Contributor
0 Kudos

And also you may restrict the selection logic!

How many variants you have? Jan to Aug,...

former_member182305
Active Participant
0 Kudos

The user is going to run the script logic to calculate next Year BUDGET based on real values. The user defined that he will select just the periods with actual Values (real).

Lets say they want to calculate budget today, then Jan to Aug wil be based on 2016 values, since Sept to dec don't have actual values, they want to calculate the average fom jan to aug and place the average fro sept to dec.

that is the definition.

former_member186338
Active Contributor
0 Kudos

Interesting requirement

In general user need to select single month (last actual month) and the rest has to be done by the script! Is it correct?

former_member182305
Active Participant
0 Kudos

yeap,

I got the first part. This first CALC depens on the account property.

The second part Im working on it. I have an idea how to calculate the average of the rest of the months (well, more less). But I don't know how know get the number of months selected by the user,

They could be Jan to Sep, jan to oct, or jan to nov, because for dec they already need the Budget approved to uplod it to ECC or do the retraction.

Is there a way to count the periods selected in the dimension %TIME_SET%??

former_member186338
Active Contributor
0 Kudos

Sample:

Let's assume TIME=2016.08

Script:

*SELECT(%Y%,YEAR,TIME,ID=%TIME_SET%)

*SELECT(%MN%,MONTHNUM,TIME,ID=%TIME_SET%)

*SELECT(%ACTPERS%,ID,TIME,ID<=%TIME_SET% AND YEAR=%Y% AND CALC=N)

*SELECT(%AVGPERS%,ID,TIME,ID>%TIME_SET% AND YEAR=%Y% AND CALC=N)

*XDIM_MEMBERSET TIME=%ACTPERS%

*WHEN TIME

*IS *

*FOR %T%=%AVGPERS%

*REC(EXPRESSION=%VALUE%/%MN%,TIME=TMVL(12,%T%))

*NEXT

*ENDWHEN

Resulting LGX in UJKT:

*XDIM_MEMBERSET TIME=2016.01,2016.02,2016.03,2016.04,2016.05,2016.06,2016.07,2016.08

*WHEN TIME

*IS

*REC(EXPRESSION=%VALUE%/8,TIME= 2017.09 )

*REC(EXPRESSION=%VALUE%/8,TIME= 2017.10 )

*REC(EXPRESSION=%VALUE%/8,TIME= 2017.11 )

*REC(EXPRESSION=%VALUE%/8,TIME= 2017.12 )

*ENDWHEN

The average values will be written to 4 months of the next year!

former_member186338
Active Contributor
0 Kudos

You simply don't need to ask user to select multiple months! Just single month - easy for user!

former_member186338
Active Contributor
0 Kudos

To copy actual months as is to the next year just add the following code at the end:

*WHEN TIME

*FOR %TA%=%ACTPERS%

*IS %TA%

*REC(EXPRESSION=%VALUE%,TIME=TMVL(12,%TA%))

*NEXT

*ENDWHEN

Result:

*WHEN TIME

*IS 2016.01

*REC(EXPRESSION=%VALUE%,TIME= 2017.01 )

*IS 2016.02

*REC(EXPRESSION=%VALUE%,TIME= 2017.02 )

*IS 2016.03

*REC(EXPRESSION=%VALUE%,TIME= 2017.03 )

*IS 2016.04

*REC(EXPRESSION=%VALUE%,TIME= 2017.04 )

*IS 2016.05

*REC(EXPRESSION=%VALUE%,TIME= 2017.05 )

*IS 2016.06

*REC(EXPRESSION=%VALUE%,TIME= 2017.06 )

*IS 2016.07

*REC(EXPRESSION=%VALUE%,TIME= 2017.07 )

*IS 2016.08

*REC(EXPRESSION=%VALUE%,TIME= 2017.08 )

*ENDWHEN

P.S. Is it clear?

former_member186338
Active Contributor
0 Kudos

P.S. If you have not standard TIME member ID's - not 2016.08 but 08.2016 (2016.AUG) then you have to use TIMEID property in selects like:

*SELECT(%Y%,YEAR,TIME,ID=%TIME_SET%)

*SELECT(%TID%,TIMEID,TIME,ID=%TIME_SET%)

*SELECT(%MN%,MONTHNUM,TIME,ID=%TIME_SET%)

*SELECT(%ACTPERS%,ID,TIME,TIMEID<=%TID% AND YEAR=%Y% AND CALC=N)

*SELECT(%AVGPERS%,ID,TIME,TIMEID>%TID% AND YEAR=%Y% AND CALC=N)

... THE REST IS THE SAME!

former_member182305
Active Participant
0 Kudos

Thank you very much for the Code Vadim,

I´ll try to incorporate this to the other I have, to marke the anwer as correct , because the other scritpt was:

Usere selects months to get the BUDGET: lets say user selects 01.2017, 02.2017..... 08.2017.

Those mohts are calculated based 01.2016, 02. 2016..... 08.2016.... so the time  scope was:

*FOR %T%=%PERIODO_SET%

  *XDIM_MEMBERSET PERIODO=TMVL(-12,%T%)

to scope year 2016. Can I change the scope during the script?

former_member186338
Active Contributor
0 Kudos

Sorry, Sebastian!

Looks like you don't understand me...

Ask user to select single month - last month with actual data!

former_member182305
Active Participant
0 Kudos

Thank you very much,

Now I got it if the user selects the last month with real DATA, then with the property you have the quantity of month...

ohhhh...

Thanks again

former_member186338
Active Contributor
0 Kudos

Yes, MONTHNUM

Answers (0)