Solved

Cannot filter query MDX

Posted on 2012-04-12
3
452 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore 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.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

786 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