Friday, February 24, 2012

How to do QTD and MTD in MDX ?

I want to use the setup as used in the "A different approach to to Time Calculations"

http://www.obs3.com/A%20Different%20Approach%20to%20Time%20Calculations%20in%20SSAS.pdf

But i still need Month to date and Quarter to date, as sepperate members in the Time calculation dimension (i know i can use the periods to date). As with the other members in the dimension this shall apply to every meassure that might be in the cube.

Can someone give an example of how to do it in MDX ?

I advise you to use AS built-in Time Intelligence Wizard. It uses Time calculation attribute rather than Time calculation dimension, but the expressions for MTD and YTD will be the same.|||

The YTD looks like this:

-- YTD CALCULATIONS

([Time Calculations].[YTD]=

Aggregate(

{[Time Calculations].&[Current Period]} *

PeriodsToDate([Time].[Calendar Hierarchy].[Year],

[Time].[Calendar Hierarchy].CurrentMember

)

));

But the MTD and QTD shall only be visible when time is on monthlevel or daylevel (for QTD) and daylevel (for MTD)

can you give an example ?

|||Hi,

I have QTD example, it work fine.

// Quarter to Date
(
[Time].[Current_QTD].[Quarter to Date],
[Time].[Quarter].[Quarter].Members,
[Time].[Date].Members
) =

Aggregate(
{ [Time].[Current_QTD].DefaultMember } *
PeriodsToDate(
[Time].[Year - Quarter - Month - Date].[Quarter],
[Time].[Year - Quarter - Month - Date].CurrentMember
)
);

Hope this work for you.

No comments:

Post a Comment