Monday, October 15, 2012

Creating YTD Calulation using MDX

Ytd function returns a set of sibling members from the same level as a given member, starting with the first sibling and ending with the given member, as constrained by the Year level in the Time dimension.
And
PeriodsToDate function returns a set of sibling members from the same level as a given member, starting with the first sibling and ending with the given member, as constrained by a specified level in the Time dimension.
One of these function can be used for YTD calculation in MDX queries.
Prior to use of these funtion, please check your Time Dimesion as below:
1. Time dimension attributes should have properites as shown below:
2. Time dimension should have hierarchies specified.
3. Time dimension should also have attribute relationships specified.
Now, you can add the calculated members within the cube to get the Year-to-date values, as below:

New Calulated Member
Name : [YTD Amount]
Parent hierarchy: Measures
Expression: SUM(PERIODSTODATE([Dim Time].[Fiscal].[Fiscal Year], [Dim Time].[Fiscal].CURRENTMEMBER),[Measures].[Amount])

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.