dbTalk Databases Forums  

Urgent! How to compare measure values between two periods?

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


Discuss Urgent! How to compare measure values between two periods? in the microsoft.public.sqlserver.olap forum.



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

Default Urgent! How to compare measure values between two periods? - 05-09-2005 , 05:00 AM






Dear all,

I have a time dimension and 6 measures. For each measure, I would like to
calculate the difference between two selected days/months/years. How can I do
this? Can I change the summary level to calculate difference, instead of
calculating sum of two selected periods? Thanks!

Polly



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

Default Re: Urgent! How to compare measure values between two periods? - 05-10-2005 , 01:02 AM






One way to achieve the same result would be to add a second time
dimension, which is essentially a copy of the first. This allows the
user to select another member, whose value can then be looked up and
subtracted (assuming you are only trying to select a pair of members):

http://groups-beta.google.com/group/...rver.olap/msg/
27564ddc49de36a1?hl=en
Quote:
Newsgroups: microsoft.public.sqlserver.olap
From: "Chris Webb [MS]"
Date: Thu, 6 Feb 2003 14:13:14 +0100

Subject: Re: Time range

Rather than let the user enter a date manually, you might want to do the
following instead: create two Time dimensions in your cube, one where
the
user can select the start of the time range and one where they select
the
end of the time range. You can then use calculated measures to return
the
aggregated values. Here's how you do this:


In your existing cube, call your Time dimension something like 'Start
Date'.
Then copy this dimension, and paste it into the same database; you will
get
a dialog asking you for a new name for this dimension, and you should
call
it something like 'End Date'. Next, create a virtual cube containing all
the
dimensions and measures from your regular cube. Since you can't add your
'End Date' dimension to this virtual cube in Analysis Manager (it isn't
connected with any cube), you need to use some DSO code to add it -
something like the following bit of VBScript is all you need:


Dim myserver
Dim db
Dim vcube
Dim fromdim
Set myserver=createobject("dso.ser*ver")
myserver.connect("MyServer")
Set db = myserver.mdstores("MyDatabase"*)
Set vcube = db.mdstores("MyVirtualCube")
Set fromdim = vcube.dimensions.addnew("End Date")
Vcube.update


You then have a virtual cube with two Time dimensions your users can use
to
set the start and end dates in their Time range. Finally you need to
create
some calculated measures that do the summing - the MDX would be
*something*
like:


SUM({
OPENINGPERIOD([START DATE].[LOWEST LEVEL], [START DATE].CURRENTMEMBER)
:
CLOSINGPERIOD([START DATE].[LOWEST LEVEL], LINKMEMBER([END
DATE].CURRENTMEMBER, [START DATE]))



}, VALIDMEASURE(MEASURES.[MY MEASURE]))


HTH,

Chris
...
Quote:

- 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.