MDX Conditional Sum using role playing date dimensions

I have a cube with a  single fact: [Measures].[order count] and two roleplaying dimensions [Order Date] and [Shipped Date]

I looking for calculated member that counts the order only if the Order Date and Shipped Date Occur in the same month.

I can do this as a TSQL case statement in the ETL; but I'm curious if there is a MDX based solution?

I'm using MSSAS 2008 R2

 

 

March 8th, 2011 6:56pm

With Set Dates as
	Generate(
		NONEMPTY(
				[Date].[Calendar].[Date]*
				[Ship Date].[Calendar].[Date],
				[Measures].[Internet Order Count]
			),
			FILTER
		(
			([Date].[Calendar].currentmember,[Ship Date].[Calendar].currentmember),
			[Date].[Calendar].currentmember.membervalue
			=[Ship Date].[Calendar].currentmember.membervalue
		)	
)
member CntWithDatesEqual as
	sum(Dates,[Measures].[Internet Order Count])
SELECT {CntWithDatesEqual} on 0
 FROM
[Adventure Works]
where
[Ship Date].[Calendar Year].&[2001]
SELECT {[Measures].[Internet Order Count]} on 0,
FILTER
(
	NONEMPTY(
		[Date].[Calendar].[Date]*
		[Ship Date].[Calendar].[Date],
		[Measures].[Internet Order Count]
	)
	,
	[Date].[Calendar].currentmember.membervalue
	= [Ship Date].[Calendar].currentmember.membervalue
)	on 1 FROM
[Adventure Works]
where
[Ship Date].[Calendar Year].&[2001]
I have made the ship date same as order date in the AW for first few data and reprocessed the cube.
Free Windows Admin Tool Kit Click here and download it now
March 9th, 2011 2:54am

Hi,

Use the MDX query like the following:

select [Measures].[Internet Order Count] on 0,
filter(
     NonEmpty([Date].[Calendar].[Date] *[Ship Date].[Calendar].[Date],[Measures].[Internet Order Count]),
     [Date].[Calendar].currentmember.parent.name = [Ship Date].[Calendar].currentmember.parent.name
     ) on 1
from [Adventure Works]

thanks,
Jerry

March 9th, 2011 10:10am

I am getting below error:

 

The NONEMPTY function expects a tuple set expression for the 1 argument. A string or numeric expression was used.

 

Any input is greatly appreciated!!

 

Thanks

Ashay

Free Windows Admin Tool Kit Click here and download it now
April 8th, 2011 2:18pm

I am also getting same error.

Kindly suggest the steps.

May 20th, 2015 1:38am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics