Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

MDX - Get MTD between two hierarchies (Month & Week) based on a week value

Avatar of stelth240
stelth240Flag for United States of America asked on
DatabasesMicrosoft SQL Server 2005SSRSSSAS
8 Comments1 Solution3416 ViewsLast Modified:
Hello Experts,

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!
WITH
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])
SELECT
{
	[Measures].[MTD Cases Shipped],
	[Measures].[MTD Cases Cut]
} ON COLUMNS,
NON EMPTY
{
	[SC Category Desc].[All].Children
} ON ROWS
FROM
	[Cube]
WHERE
    StrToMember(@ToWeek).LastChild //@ToWeek = [Yr - Week - Date].[W2010-13]
ASKER CERTIFIED SOLUTION
Avatar of Tim Humphries
Tim HumphriesFlag of United Kingdom of Great Britain and Northern Ireland imageDirector

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answers