dbTalk Databases Forums  

Help with Calculating Moving Average in Cube

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


Discuss Help with Calculating Moving Average in Cube in the microsoft.public.sqlserver.olap forum.



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

Default Help with Calculating Moving Average in Cube - 01-20-2006 , 10:47 AM






Sorry if this is a simple question, but I'm very new at OLAP.

In SQL 2005 I am trying to calculate a 12-month moving average for a measure
in my cube and I'm having a little trouble. The average seems to reset
itself as it crosses boundaries in the time hierarchy.

I'm using the following calculation in the cube to get my 12-month rolling
average:

Avg ([Time].[CalendarMonth].CurrentMember.Lag(12) :
[Time].[CalendarMonth].CurrentMember,
[Measures].[Revenue Actual])

My cube looks like this:

Time Dimension:
*CalendarYear
**CalendarQuarter
***CalendarMonth

Fact_Revenue
Fulldate, Program_Name, Revenue_Actual, Revenue_Plan


When calculating the averages, it resets itself as soon as it passes a YEAR
or QUARTER boundary. For example, if I look at (2004, Q1, Month 3) it will
show a correct average for only the 2004 Q1 Months 1,2 and 3. It is not
able to figure in the averages of values that fall in a different quarter or
year.

I'm not sure if this is an error with my MDX expression, my Time dimension,
or what. Does anyone have any suggestions on how to do this?

Thanks,

-s





Reply With Quote
  #2  
Old   
Vladimir Chtepa
 
Posts: n/a

Default Re: Help with Calculating Moving Average in Cube - 01-24-2006 , 07:30 AM






Hi Stephen

What version of AS do you have?
Is [Time].[CalendarMonth] a hierarchy level or a hierarchy?

Thanks,
Vladimir Chtepa

"Stephen Sanders" <fake (AT) fake (DOT) com> schrieb im Newsbeitrag
news:Og76mEeHGHA.1100 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Quote:
Sorry if this is a simple question, but I'm very new at OLAP.

In SQL 2005 I am trying to calculate a 12-month moving average for a
measure in my cube and I'm having a little trouble. The average seems to
reset itself as it crosses boundaries in the time hierarchy.

I'm using the following calculation in the cube to get my 12-month rolling
average:

Avg ([Time].[CalendarMonth].CurrentMember.Lag(12) :
[Time].[CalendarMonth].CurrentMember,
[Measures].[Revenue Actual])

My cube looks like this:

Time Dimension:
*CalendarYear
**CalendarQuarter
***CalendarMonth

Fact_Revenue
Fulldate, Program_Name, Revenue_Actual, Revenue_Plan


When calculating the averages, it resets itself as soon as it passes a
YEAR or QUARTER boundary. For example, if I look at (2004, Q1, Month 3)
it will show a correct average for only the 2004 Q1 Months 1,2 and 3. It
is not able to figure in the averages of values that fall in a different
quarter or year.

I'm not sure if this is an error with my MDX expression, my Time
dimension, or what. Does anyone have any suggestions on how to do this?

Thanks,

-s







Reply With Quote
  #3  
Old   
Stephen Sanders
 
Posts: n/a

Default Re: Help with Calculating Moving Average in Cube - 01-24-2006 , 11:28 AM



I am using Analysis Server 2005 that was installed with SQL 2005.
[Time.CalendarMonth] is a hierarchy level. My complete time dimension is
like this:

[TIME]
*[CalendarYear]
**[CalendarQuarter]
***[CalendarMonth]
****[FullDate]

Thanks,

-s


"Vladimir Chtepa" <vc.nospam (AT) diacom-systemhaus (DOT) nospam.de> wrote

Quote:
Hi Stephen

What version of AS do you have?
Is [Time].[CalendarMonth] a hierarchy level or a hierarchy?

Thanks,
Vladimir Chtepa

"Stephen Sanders" <fake (AT) fake (DOT) com> schrieb im Newsbeitrag
news:Og76mEeHGHA.1100 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Sorry if this is a simple question, but I'm very new at OLAP.

In SQL 2005 I am trying to calculate a 12-month moving average for a
measure in my cube and I'm having a little trouble. The average seems to
reset itself as it crosses boundaries in the time hierarchy.

I'm using the followling calculation in the cube to get my 12-month
rolling average:

Avg ([Time].[CalendarMonth].CurrentMember.Lag(12) :
[Time].[CalendarMonth].CurrentMember,
[Measures].[Revenue Actual])

My cube looks like this:

Time Dimension:
*CalendarYear
**CalendarQuarter
***CalendarMonth

Fact_Revenue
Fulldate, Program_Name, Revenue_Actual, Revenue_Plan


When calculating the averages, it resets itself as soon as it passes a
YEAR or QUARTER boundary. For example, if I look at (2004, Q1, Month 3)
it will show a correct average for only the 2004 Q1 Months 1,2 and 3. It
is not able to figure in the averages of values that fall in a different
quarter or year.

I'm not sure if this is an error with my MDX expression, my Time
dimension, or what. Does anyone have any suggestions on how to do this?

Thanks,

-s









Reply With Quote
  #4  
Old   
Vladimir Chtepa
 
Posts: n/a

Default Re: Help with Calculating Moving Average in Cube - 01-24-2006 , 08:20 PM



You should take current member on the hierarchy not on the hierarchy level.
How many hierarchies do you have in the time dimension?

Please, look at this example, that i write for AW sample database.

with

member [measures].[glidingavg] as
avg([Date].[Calendar].currentmember.lag(12):[Date].[Calendar].currentmember,
[Measures].[Internet Sales Amount])

select
{[Measures].[Internet Sales Amount], [measures].[glidingavg]} on 0,
{[Date].[Calendar].[Month].members} on 1
from [Adventure Works]

Vladimir Chtepa

"Stephen Sanders" <fake (AT) fake (DOT) com> schrieb im Newsbeitrag
news:%237y0WuQIGHA.2948 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Quote:
I am using Analysis Server 2005 that was installed with SQL 2005.
[Time.CalendarMonth] is a hierarchy level. My complete time dimension is
like this:

[TIME]
*[CalendarYear]
**[CalendarQuarter]
***[CalendarMonth]
****[FullDate]

Thanks,

-s


"Vladimir Chtepa" <vc.nospam (AT) diacom-systemhaus (DOT) nospam.de> wrote in message
news:eqe7LpOIGHA.3728 (AT) tk2msftngp13 (DOT) phx.gbl...
Hi Stephen

What version of AS do you have?
Is [Time].[CalendarMonth] a hierarchy level or a hierarchy?

Thanks,
Vladimir Chtepa

"Stephen Sanders" <fake (AT) fake (DOT) com> schrieb im Newsbeitrag
news:Og76mEeHGHA.1100 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Sorry if this is a simple question, but I'm very new at OLAP.

In SQL 2005 I am trying to calculate a 12-month moving average for a
measure in my cube and I'm having a little trouble. The average seems
to reset itself as it crosses boundaries in the time hierarchy.

I'm using the followling calculation in the cube to get my 12-month
rolling average:

Avg ([Time].[CalendarMonth].CurrentMember.Lag(12) :
[Time].[CalendarMonth].CurrentMember,
[Measures].[Revenue Actual])

My cube looks like this:

Time Dimension:
*CalendarYear
**CalendarQuarter
***CalendarMonth

Fact_Revenue
Fulldate, Program_Name, Revenue_Actual, Revenue_Plan


When calculating the averages, it resets itself as soon as it passes a
YEAR or QUARTER boundary. For example, if I look at (2004, Q1, Month 3)
it will show a correct average for only the 2004 Q1 Months 1,2 and 3.
It is not able to figure in the averages of values that fall in a
different quarter or year.

I'm not sure if this is an error with my MDX expression, my Time
dimension, or what. Does anyone have any suggestions on how to do this?

Thanks,

-s











Reply With Quote
  #5  
Old   
Stephen Sanders
 
Posts: n/a

Default Re: Help with Calculating Moving Average in Cube - 01-26-2006 , 09:12 AM



That worked nicely! Thank you for your help.

-s

"Vladimir Chtepa" <vc.nospam (AT) diacom-systemhaus (DOT) nospam.de> wrote

Quote:
You should take current member on the hierarchy not on the hierarchy
level.



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.