on 10-25-2012 9:51 AM
Hi,
I have a requirement to create a macro for calculating Average forecast. Avg forecast Calculation: sum of weekly qty / number of weeks.
For eg:-
W1 | W2 | W3 | W4 | W5 |
0 | 200 | 423 | 0 | 200 |
Number of weeks considered are from W2 to W5=4 weeks excluding the weeks which have no fcst & considering the week which have fcst till total horizon in defining the number of weeks.
Can you explain the steps for developing the macro?
Thanks,
Rajeev
Hi Rajeev,
Please check the following pseudo code that might give you an idea on macro implementation.
Step 1: Initialize the variables (1 iteration)
- Use action element box
LAYOUTVARIABLE_SET( 'sum' ; SUM function for required horizon )
LAYOUTVARIABLE_SET( 'counter' ; 0 )
Step 2: Increment counter (1 .. n iterations)
IF ( ROW:FORECAST[i] > 0 )
LAYOUTVARIABLE_SET ( 'counter' ; EVAL( LAYOUTVAR_VALUE( 'counter ' ) + 1 ) )
ENDIF
Step 3: Calculate avg of non-zero forecast values (1 iterations)
avg value = EVAL( LAYOUTVAR_VALUE( 'sum' ) / LAYOUTVAR_VALUE( 'counter' ) )
Thanks,
Rajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
4 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.