on 2023 Apr 25 2:18 PM
Hello Experts,
Can you please help with the below request
My Requirement:
I have to take values from a range of past periods that are defined by the user in runtime (as Input Parameters), then calculate the average of these values and post the result average amount to the next 42 periods (starting from current period).
For Example:
Past Periods Range: Jan.2022 to May.2022
Future Periods: April.2023 to October.2026
In Advanced Formula, I have defined the scope of the future periods as:
MEMBERSET [d/Date] = PERIOD(TODAY()) TO NEXT(42,"MONTH", TODAY())
How to Calculate the Average value from the past periods (as they are not part of the memberset scope).
I have tried using FOREACH, Variables, etc.but unable to achieve this as Resultlookup doesn't accept Range.
Thanks for your help.
Regards
Malya
Request clarification before answering.
malya_7
Your Date scope should be on periods for which Average has to be calculated. See an example below.
Parameter:
Advanced Formula: Adjust as per your model dimension names and measures
MEMBERSET [d/MEASURE] = "QUANTITY"
MEMBERSET [d/CALMONTH]=%Average_Period% // Parameter for Average periods
MEMBERSET [d/SAP_CEP_PRODUCT] = "A"
VARIABLEMEMBER #TOTAL OF [d/CALMONTH]
VARIABLEMEMBER #NUM OF [d/CALMONTH]
FLOAT @AVG
INTEGER @COUNT
@AVG=0.0
DATA([d/CALMONTH] = #TOTAL) = RESULTLOOKUP()
DATA([d/CALMONTH] = #NUM) = RESULTLOOKUP() * 0 + 1
@AVG = RESULTLOOKUP([d/CALMONTH] = #TOTAL) / RESULTLOOKUP( [d/CALMONTH] = #NUM)
FOR @COUNT = 0 TO 41 // adjust this for your future periods
DATA([d/CALMONTH]=NEXT(@COUNT,"MONTH",TODAY()))=@AVG
ENDFOR
Data Action Run:
Output: I ran for only 8 periods i.e. @COUNT = 0 TO 8. You can see the average was 250/5 = 50
Hope this helps !!
Please upvote/accept if this helps
Nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
74 | |
30 | |
9 | |
8 | |
8 | |
7 | |
7 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.