Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cannot filter query MDX

Posted on 2012-04-12
3
Medium Priority
?
478 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

670 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