dbTalk Databases Forums  

YTD vs Last 12 periods

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


Discuss YTD vs Last 12 periods in the microsoft.public.sqlserver.olap forum.



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

Default YTD vs Last 12 periods - 03-14-2006 , 09:32 AM






Hi,

We have a cube where we will show the last date of teh month as the
total of a month and the average of all dates in a month as the result
for a month. So if you look at 15 feb you should see data based on data
between 15-feb 2005 and 2006.

We will use a Time slicer as page filter and have always any choice
(Year or Month or Date) show the correct data.

What is the mdx code to show always the correct data if you choice for
example 2006, feb 2006 or even 15 feb 2006.

Regards, Marco


Reply With Quote
  #2  
Old   
pras
 
Posts: n/a

Default Re: YTD vs Last 12 periods - 03-15-2006 , 01:04 AM






use "LastPeriods" MDX function
AVG or Sum whatever it is

AVG(Lastperiods(12,Time.currentmember),[Measures].[sales])


regards,
Pras


Reply With Quote
  #3  
Old   
pras
 
Posts: n/a

Default Re: YTD vs Last 12 periods - 03-15-2006 , 01:05 AM



use "LastPeriods" MDX function
AVG or Sum whatever it is

AVG(Lastperiods(12,Time.currentmember),[Measures].[sales])


regards,
Pras


Reply With Quote
  #4  
Old   
Marco
 
Posts: n/a

Default Re: YTD vs Last 12 periods - 03-16-2006 , 04:00 AM



Hi,

Thank you this is working for if you choice for example a month but
what would be the MDX code if you choice for example a date 1 feb 2006
and you would like to show always the average of the last 12 periods (=
months).

Regards, Marco


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

Default Re: YTD vs Last 12 periods - 03-16-2006 , 05:35 AM



As I mentioned off-line (I thought I would answer here too incase
someone else is watching this thread), you could do something like:

Quote:
AVG(Lastperiods(12,Ancestor([Time].Currentmember,[Time].
[Month]).PrevMember),[Measures].[Sales])
Quote:
If you are on the month level, it will return the current month. If you
are lower than month it will work it's way up the heirarchy to the month
level.

You may want different logic if the user picks a level higher than
month, you could handle that with an IIF() function.

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

In article <1142501063.927103.110050 (AT) v46g2000cwv (DOT) googlegroups.com>,
olap (AT) gmsbv (DOT) nl says...
Quote:
Hi,

Thank you this is working for if you choice for example a month but
what would be the MDX code if you choice for example a date 1 feb 2006
and you would like to show always the average of the last 12 periods (=
months).

Regards, Marco



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.