on 07-07-2014 1:07 PM
Hi experts,
I need to have in the parent members of the dimension TIME (2014.Q1, 2014.Q2, 2014.Q3, 2014.Q4, 2014.TOTAL) the average value of their children and not the sum. For example :
2014.01 2014.02 2014.03 2014.Q1
1 2 3 2
2 = AVG(1, 2, 3)
I tried the script bellow but it doesn't work , it throws the error " ReferenceError : AVG is not defined"
*SELECT(%TIMESET%,"[ID]",TIME,"[CALC]='Y'")
*XDIM_MEMBERSET TIME = %TIMESET%
*XDIM_MEMBERSET MEASURES = PERIODIC
*WHEN DIM1
*IS C02
*WHEN TIME
*IS %TIMESET%
*REC(EXPRESSION = AVG(Descendants([%TIMESET%].CURRENTMEMBER)), TIME = %TIMESET%)
*ENDWHEN
*ENDWHEN
*COMMIT
How can I achieve this ?
Thanks
Maha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The best way is to enter 2 accounts: Productivity and Area, calculating by dimension member formula:
ProductivityPerHectare=IIF([Area]=0,NULL,[Productivity]/[Area])
If you have to enter ProductivityPerHectare and Area, then in script you can calculate Productivity:
*WHEN ACCOUNT
*IS Area
*REC(EXPRESSION=%VALUE%*[ACCOUNT].[ProductivityPerHectare],ACCOUNT=Productivity)
*ENDWHEN
*WHEN ACCOUNT
*IS ProductivityPerHectare //user input
*REC(EXPRESSION=%VALUE%*[ACCOUNT].[Area],ACCOUNT=Productivity)
*ENDWHEN
Then dimension member formula:
ProductivityPerHectareCalc=IIF([Area]=0,NULL,[Productivity]/[Area])
You can use arithmetic average of ProductivityPerHectare only if Area is always constant.
In this case you can create some dummy account member DUMMY and fill it with 1:
*WHEN ACCOUNT
*IS ProductivityPerHectare //user input
*REC(EXPRESSION=1,ACCOUNT=DUMMY)
*ENDWHEN
Then dimension member formula:
ProductivityPerHectareCalc=IIF([DUMMY]=0,NULL,[ProductivityPerHectare]/[DUMMY])
Vadim
You don't need any TIME dimension in the dimension member formula or in some script. The dimension member formula will correctly calculate result for any period (base or parent):
2014.01 10/10=1
2012.02 40/20=2
2014.03 90/30=3
2014.Q1=(10+40+90)/(10+20+30)=140/60=2,333
2,333 - is a correct weighted average, 2 - incorrect arithmetic average!
Vadim
User | Count |
---|---|
12 | |
3 | |
1 | |
1 | |
1 | |
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.