That's an interesting way of doing a forecast. If I had your set of requirements and the cube structure as you have it I would
1) Create YTD consolidations in the '4 Laikotarpiai' dimension. E.g. '2011.01 YTD' has the child '2011.01'. '2011.03 YTD' has '2011.01', '2011.02, and '2011.03'. You'd need a YTD figure for every single month of the year.
2) I would still have my "Actual" or "Forecast" as an attribute of the Laikotarpiai dimension, rather than in the 'Flag' element.
3) Have a 'Prev' text attribute in the Laikotarpiai dimension that has the previous month. E.g. 2011.02 will have 2011.01 as its 'Prev' attribute.
4) The rule would look something like this
Code: Select all
['Forecast'] = N:
# If actual, then leave for entry
if(attrn('Laikotarpiai', !Laikotarpiai, 'IsActual')=1, stet,
# otherwise it is forecast. If last month was also a forecast then use that
if(attrn('Laikotarpiai', attrs('Laikotarpiai', !Laikotarpiai, 'Prev'), 'IsActual')=0,
DB('Balansas', !Dim1, !Dim2, !Dim3, attrs('Laikotarpiai', !Laikotarpiai, 'Prev'), 'Forecast'),
# otherwise this month is forecast, but last month is actuals
# so get the sum of actuals for all the months up to last month by using last month's YTD consolidation
DB('Balansas', !Dim1, !Dim2, !Dim3, attrs('Laikotarpiai', !Laikotarpiai, 'Prev') | ' YTD', 'Forecast') \
# and divide by the number of months in the YTD
elcompn('Laikotarpiai', attrs('Laikotarpiai', !Laikotarpiai, 'Prev') | ' YTD')));
I haven't tested it, there might be a few parentheses that need adding or removing. Also, you'll need to cater for the special case of 20xx.01, where there is no history to use to get the average.
HTH,
Martin