dbTalk Databases Forums  

Average of Children Aggregate over Time

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


Discuss Average of Children Aggregate over Time in the microsoft.public.sqlserver.olap forum.



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

Default Average of Children Aggregate over Time - 07-12-2006 , 12:40 PM






Hi ,
as I understand, the concept of AverageOfChildren aggregate function
applies, when aggregation is done via the time dimension. Is there a elegant
way to handle missing values as 0?

let's say, we have the following fact table,
TimeDim: Measure ACT
Mo: 2
Tu: -- missing (no entry in Fact Table)
We: 1
Th: -- missing
Fr:-- missing
Sa: 3
So: 8

The AverageOfChildreen function will return a week-value of 3.5 = (2+1+3+8)
/ 4

What I would like to have is a value of 2 = (2+0+1+0+0+3+8)/7 (days in a
week as setup in the time dimension)

Obviously we can solve this issue by creating a calculated measure based on
the ACT (Using SUM as aggregate function)
IIF(

( ISLEAF([Day].[~ ISO Date].CURRENTMEMBER)

),

IIF(ISEMPTY([Measures].[ACT]),0,[Measures].[ACT]),

IIF(ISEMPTY([Measures].[ACT]),0,[Measures].[ACT]) / [Measures].[Day Count]

)

Any better ideas, will be truly appreciated.

Thanks

Björn



Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: Average of Children Aggregate over Time - 07-12-2006 , 09:55 PM






Hi Björn,

How about adding a scoped calculation to the cube MDX script, rather
than a calculated measure - the ACT measure should still use
AverageOfChildren aggregate function:

Quote:
/*
Zero out time leaves of an AverageOfChildren measure:
*/

Scope([Measures].[ACT]);
Scope(Leaves([TimeDim]));
this = CoalesceEmpty([Measures].[ACT], 0);
End Scope;
End Scope;
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


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

Default Re: Average of Children Aggregate over Time - 07-13-2006 , 11:02 AM



Works fine,
thank's Deepak

"Deepak Puri" <deepak_puri (AT) progressive (DOT) com> schrieb im Newsbeitrag
news:OHHbVfipGHA.4032 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
Quote:
Hi Björn,

How about adding a scoped calculation to the cube MDX script, rather
than a calculated measure - the ACT measure should still use
AverageOfChildren aggregate function:


/*
Zero out time leaves of an AverageOfChildren measure:
*/

Scope([Measures].[ACT]);
Scope(Leaves([TimeDim]));
this = CoalesceEmpty([Measures].[ACT], 0);
End Scope;
End Scope;



- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***



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.