I'm writing an MDX query in SQL Server 2005 SSRS.
I'm trying to get a MTD value but I have to go through two hierarchies to get it. We have two time hierarchies in our cube: [Year - Week - Date] and [Year - Month - Date]. The data that's coming in to the query (this is built for Reporting Services) is a week member. I'd like to get the last day of that week (using LastChild) and somehow translate that over to the Month hierarchy for the same date. Then I'd like to get the MTD value from that date. Is that possible?
Here's an example:
Let's say the current week is W2010-13, from the week hierarchy. In our cube, this date spans over March and April, but the last day of that week is in April (2010-04-03). I'd like to get the MTD associated with that date based on the Month hierarchy (April 1 - April 3).
Below is an example of what I'm trying to accomplish, though I know it's not correct. I'm fairly new to MDX so I don't understand most of the functions within the language. I believe part of my issue is the WHERE clause is filtering down to one day so the MTD won't ever give me the correct data regardless of the hierarchies. How do I specify a date as a "current member" without causing it to filter the data?
Thank you in advance for any help!
MEMBER [Measures].[MTD Cases Shipped] AS
SUM(MTD([Yr - Month - Date].CurrentMember), [Measures].[Cases Shipped])
MEMBER [Measures].[MTD Cases Cut] AS
SUM(MTD([Yr - Month - Date].CurrentMember), [Measures].[Cases Cut])
[Measures].[MTD Cases Shipped],
[Measures].[MTD Cases Cut]
} ON COLUMNS,
[SC Category Desc].[All].Children
} ON ROWS
StrToMember(@ToWeek).LastChild //@ToWeek = [Yr - Week - Date].[W2010-13]