Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hey,
I would like to calculate a twelve month rolling chart which is independend from it's time dimension.
Dimensions:
Variables:
Expression:
=SUM(
{<
period_year={'<$(v_mr_top_limit)>$(v_mr_bottom_limit)'}
>} AGGR(
RANGESUM(
ABOVE(
TOTAL SUM(
{<
period_year
>} values
)
,
0
,
12
)
)
,
period_year
)
)
I have expected to see the same value as if I have used the internal chart accumulation function.
I have no idea what causes the problem.
Any suggestions?
Best
Simon
I think I have solved the problem on my own
The reason for incorrect calculation is the sort order AGGR() uses because it does not use the current sort order from the chart but the original load order.
In my example this sort order is 2015.1, 2015.10, 2015.11, 2015.12, 2015.2,... etc.
To solve this problem I have done a pre-calculation of the dates and insert my data with a left join.
LET v_month_difference = 18;
LET v_period_year_min = (MAKEDATE(2014,1,1);
FOR i=0 TO ($(v_month_difference)-1)
FACTDATA:
LOAD
$(i)+1 AS sort
,DATE(ADDMONTHS($(v_period_year_min),$(i)),'MM.YYYY') AS period_year
AUTOGENERATE(1)
;
NEXT i;
I think I have solved the problem on my own
The reason for incorrect calculation is the sort order AGGR() uses because it does not use the current sort order from the chart but the original load order.
In my example this sort order is 2015.1, 2015.10, 2015.11, 2015.12, 2015.2,... etc.
To solve this problem I have done a pre-calculation of the dates and insert my data with a left join.
LET v_month_difference = 18;
LET v_period_year_min = (MAKEDATE(2014,1,1);
FOR i=0 TO ($(v_month_difference)-1)
FACTDATA:
LOAD
$(i)+1 AS sort
,DATE(ADDMONTHS($(v_period_year_min),$(i)),'MM.YYYY') AS period_year
AUTOGENERATE(1)
;
NEXT i;