dbTalk Databases Forums  

custom rollup??? I am lost

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


Discuss custom rollup??? I am lost in the microsoft.public.sqlserver.olap forum.



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

Default custom rollup??? I am lost - 11-12-2004 , 05:14 PM






Here is my dim_prod structure: prod->cat->subcat->type->sku
I have two measures: sales, forecast. I need to calculate "needed". The
problem is that the formulas needs to be different at different level:

At the sku and type level, needed = (Sales - |Sales - forecast|)/Sales.
At the subcat, cat and prod level, needed = (sales - (sum of
Quote:
sales-forecast| at type level))/sales:
sales fc |sales-fc| needed

sku1 100 70 30 .7
(right)
sku2 100 110 10 .9
(right)
type1 200 180 20 .9
(right)
sku3 ...

sku4 ...

type2 200 220 20 .9
(right)
subcat1 400 400 0 1.0
(wrong)

the "needed" should be (400 - (20+20))/400 = .9. How do I do that? Is that
some type of custom rollup?



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

Default Re: custom rollup??? I am lost - 11-13-2004 , 12:40 AM






Define the "needed" calculated measure as follows:

Quote:
With Member [Measures].[needed] as
'([Measures].[sales] - iif(
[dim_prod].CurrentMember.Level.Ordinal >=
[dim_prod].[type].Ordinal,
Abs([Measures].[sales] - [Measures].[fc]),
Sum(Descendants([dim_prod].CurrentMember,
[dim_prod].[type]),
Abs([Measures].[sales] - [Measures].[fc]))))
/ [Measures].[sales]'
Quote:

- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


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.