Annualization in MDX -
introduction i'm doing maintenance job on measure annualizes (ytd) measure. granularity of measures month. annualization works fine on month level, when use parents in date hierachy calculation not work.
it should work this:
measureannualized = ytdmeasure * (currentmonth / 12)
currentmonth implemented
closingperiod([date].[datehierarchy].[month], [date].[datehierarchy]).membervalue
on month level works fine:
month measureytd measureannualized closingperiod july -50 -85,71 7 august -60 -90,00 8 september (null) (null) 9
but on higher level in datehierarchy not work. instance on quarter level:
quarter measureytd measureannualized closingperiod 3 -60 -80,00 (should : -90,00) 9 (should be: 8)
as can see, picks closingperiod of quarter 3 (=9) whereas should last "non-empty" closingperiod (=8). same applies year level:
year measureytd measureannualized closingperiod 2016 -60 -60,00 (should : -90,00) 12 (should be: 8)
the question therefore is: how can closingperiod last period in ytd measure not (null)?
in definition on msdn of closingperiod
gives equivalent nested version of same logic:
tail(descendants(member_expression, level_expression), 1)
the below similar added nonempty
:
with member measures.[lastnonempty] tail ( nonempty ( (existing [date].[calendar].[month]) ,[measures].[internet sales amount] ) ,1 ).item(0).membervalue select measures.[lastnonempty] on 0 ,[date].[calendar].[calendar year].members on 1 [adventure works];
it returns following:
Comments
Post a Comment