Solved

Cannot filter query MDX

Posted on 2012-04-12
3
446 Views
Last Modified: 2013-01-24
I have created the following MDX Query to determine a date + 91 Days which I am then going to use this as a dataset for a parameter in a SRSS report:  
WITH

	Member [Measures].[StartDateValue] As [Time - Expected Receipt Date].[Date].CURRENTMEMBER.UNIQUENAME
	Member [Measures].[StartWeek] As [Time - Expected Receipt Date].[Fiscal Year And Week].CurrentMember.Name
	MEMBER [Measures].[DayOfWeek] As datepart("w",[Time - Expected Receipt Date].[Date].CURRENTMEMBER.Member_Name)
	Member [Measures].[EndDateValue] As membertostr(StrToMember("[Time - Expected Receipt Date].[Date].&" + Format( CDate(DateAdd('d',91, [Time - Expected Receipt Date].[Date].CurrentMember.Name)), "[yyyy-MM-ddTHH:mm:ss]" ) ))
	
Select
	{
		[Measures].[DayOfWeek],
		[Measures].[StartDateValue],
		[Measures].[StartWeek],
		[Measures].[EndDateValue]
	} On Columns,
		[Time - Expected Receipt Date].[Date].[Date]  On Rows
From
	[Retail] 

Open in new window


I now want to filter this on the measure [DayOfWeek] to only show the 7's (Sunday) so I do not get duplicates in my Paramter, which I do by amending the code as follows:

WITH

	Member [Measures].[StartDateValue] As [Time - Expected Receipt Date].[Date].CURRENTMEMBER.UNIQUENAME
	Member [Measures].[StartWeek] As [Time - Expected Receipt Date].[Fiscal Year And Week].CurrentMember.Name
	MEMBER [Measures].[DayOfWeek] As datepart("w",[Time - Expected Receipt Date].[Date].CURRENTMEMBER.Member_Name)
	Member [Measures].[EndDateValue] As membertostr(StrToMember("[Time - Expected Receipt Date].[Date].&" + Format( CDate(DateAdd('d',91, [Time - Expected Receipt Date].[Date].CurrentMember.Name)), "[yyyy-MM-ddTHH:mm:ss]" ) ))
	
Select
	{
		[Measures].[DayOfWeek],
		[Measures].[StartDateValue],
		[Measures].[StartWeek],
		[Measures].[EndDateValue]
	} On Columns,
		filter([Time - Expected Receipt Date].[Date].[Date], [Measures].[DayOfWeek] = 7)  On Rows
From
	[Retail]

Open in new window



However when I run it I get the following Error:

Executing the query ...
Execution of the managed stored procedure datepart failed with the following error: Exception has been thrown by the target of an invocation.Argument 'DateValue' cannot be converted to type 'Date'..

Execution complete


Any advice anyone could give would be greatly appreciated.

Many Thanks

Jon
0
Comment
Question by:McSsporran
3 Comments
 
LVL 15

Accepted Solution

by:
Tim Humphries earned 500 total points
ID: 37855557
Hi Jon,

Have you tried converting [Time - Expected Receipt Date].[Date].CURRENTMEMBER.Member_Name to a date type explicitly using CDate() first?

Maybe the member_name isn't in the correct format to convert to a date properly (or maybe you have an 'unknown' member which is failing conversion?)

Tim
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now