dbTalk Databases Forums  

MDX Expression Same Month Last Year Month To Date

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss MDX Expression Same Month Last Year Month To Date in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jamin Mace
 
Posts: n/a

Default MDX Expression Same Month Last Year Month To Date - 12-14-2005 , 06:25 PM






Basically the measure entails pulling net sales Month To Date for the same
day last year as the currently selected day node in my time dimension. ie.,
Today is December 14th, 2005. They want net sales for Month To Date for
December 14th, 2004. At first glance this seemed rather trivial, I used the
ParallelPeriod function. However this function does not find the exact same
date it finds the relative calendar date. ie. today is 2nd Wednesday of
December 05, so it returns that parallel period in 04 not the 14th. I can
use the lag function and Lag(365), however this solution will not accommodate
for leap year. Do you have any MDX that would calculate in Leap Year? My
MDX expression is below:

Sum(

PeriodsToDate

(

[Time].[By Fiscal Year PSP].[The Month],

ParallelPeriod

(

[Time].[By Fiscal Year PSP].[The Fiscal Year], 1,

StrToMember

(

IIf(

IsEmpty([Time].[By Fiscal Year PSP] .CurrentMember.LastChild

) ,

"[Time].[By Fiscal Year PSP] .CurrentMember",

"[Time].[By Fiscal Year PSP] .CurrentMember.LastChild"

)

)

)

)

, [Net Sales]

)


Thanks for your help in advance.


Reply With Quote
  #2  
Old   
Darren Gosbell
 
Posts: n/a

Default Re: MDX Expression Same Month Last Year Month To Date - 12-17-2005 , 11:25 PM






I think ParallelPeriod would only do this if there was an intermediate
level, like weeks. Otherwise it should find the correct relative member.

It looks from the syntax like you might be using AS 2005. If are using a
hierarchy with a level in between months and days - can you try setting
up one that goes straight from months to days and try using that?

--
Regards
Darren Gosbell [MCSD]
Blog: http://www.geekswithblogs.net/darrengosbell

In article <F336F6D7-AB70-4F27-A2C1-2CCC3A5D3590 (AT) microsoft (DOT) com>, "=?Utf-
8?B?SmFtaW4gTWFjZQ==?=" <Jamin Mace (AT) discussions (DOT) microsoft.com> says...
Quote:
Basically the measure entails pulling net sales Month To Date for the same
day last year as the currently selected day node in my time dimension. ie.,
Today is December 14th, 2005. They want net sales for Month To Date for
December 14th, 2004. At first glance this seemed rather trivial, I used the
ParallelPeriod function. However this function does not find the exact same
date it finds the relative calendar date. ie. today is 2nd Wednesday of
December 05, so it returns that parallel period in 04 not the 14th. I can
use the lag function and Lag(365), however this solution will not accommodate
for leap year. Do you have any MDX that would calculate in Leap Year? My
MDX expression is below:

Sum(

PeriodsToDate

(

[Time].[By Fiscal Year PSP].[The Month],

ParallelPeriod

(

[Time].[By Fiscal Year PSP].[The Fiscal Year], 1,

StrToMember

(

IIf(

IsEmpty([Time].[By Fiscal Year PSP] .CurrentMember.LastChild

) ,

"[Time].[By Fiscal Year PSP] .CurrentMember",

"[Time].[By Fiscal Year PSP] .CurrentMember.LastChild"

)

)

)

)

, [Net Sales]

)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.