on 12-18-2012 3:26 PM
Hello
I want to calculate Average of Forecast for a particular planning horizon (12Months) but only for months with value greater than 0
Example
Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec
10 20 30 0 40 15 0 50 0 20 10 47
The Average should be 237/ 9 and NOT 237 / 12.
How can I achieve this in APO Macro?
Initialize a counter that counts only when the value is greater than 0 etc ….
Hello,
Here is some raw code that can help you in determining the number of periods with non zero
values.
Macro Name
Set loop variable
LAYOUTVARIABLE_SET('LP' ; 1)
Do loop
Step for loop ( define number of Iterations )
if Keyfigure value > 0
Action box increment the counter
LAYOUTVARIABLE_SET('LP';(LAYOUTVAR_VALUE('LP')+1))
end if
enddo
This above pseudo code will help you to calulate the number of periods with non zero value.
then you can use normal Sum to get the sum of the key figure values for the whole horizon.
Average can be calculated by dividing the sum by number of periods with non zero values.
Hope this helps you.
Regards,
Anurag
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
yes, there is no other way. Define a STEP (1 iteration) to initialize counter (sum and number of periods actually used) and a second STEP that adds the iteration history to the sum variable and increments the number of periods IF history>0. Third STEP that divides sum by number of periods... Standard functions and forecast models will consider zeroes as valid history values and include them in the calculations.
thanks,
J.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
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.