Solved

Cannot filter query MDX

Posted on 2012-04-12
3
463 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

734 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