Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MDX Date Range calculated member

Status
Not open for further replies.

dimitemma

MIS
Sep 14, 2010
1
GR
Hi,

I have [Sales Amount] and [Date].
How can I create a calculated member that will aggregate only the values from [Sales Amount] where month([Date]) is 'Jan' or 'Feb' and year is CurrentYear ?
Then 'Mar' & 'Apr' and so on.

Thank you.
D.
 
Well, no one can really provide you with the exact code without knowing the schema of your database. I also suggest to debug this first in an MDX query and then store the calculated measures.

For example, if you have a Date attribute called "Month Of Year," with the values of 1,2,3,4,5,6,etc., and you have an attribute called "Year" with values like 2000, 2001, 2002, etc., then you could try something like the following:

Code:
WITH 

MEMBER [Measures].[Current Year Jan-Feb Sales] 
AS SUM(
({[Date].[Month Of Year].&[1], [Date].[Month Of Year].&[2]}, 
StrToMember('[Date].[Year].&[' + CSTR(YEAR(NOW())) + ']')),
[Measures].[Sales Amount])

MEMBER [Measures].[Current Year Mar-Apr Sales] 
AS SUM(
({[Date].[Month Of Year].&[3], [Date].[Month Of Year].&[4]}, 
StrToMember('[Date].[Year].&[' + CSTR(YEAR(NOW())) + ']')),
[Measures].[Sales Amount])


SELECT {[Measures].[Current Year Jan-Feb Sales] , [Measures].[Current Year Mar-Apr Sales] } ON 0
FROM [Your Cube]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top