dbTalk Databases Forums  

TimeSpan / Calculation within TimePeriod

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


Discuss TimeSpan / Calculation within TimePeriod in the microsoft.public.sqlserver.olap forum.



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

Default TimeSpan / Calculation within TimePeriod - 03-21-2005 , 08:21 AM






Hello
I have prob with calculating Measures with a timeperiod.

Its about customers in a supermarket.

ROWDATA
CustomerID
VisitStartTime
VisitEndTime
Spending

TimeDimension
Year, Month, Day, Hour; Minute

I know how to calculate Total-Spendings along TimeDimension based on
VisitEndTime, no Prob.

Question:
How can I calculate the number of Customers that are in the Supermarket
(started shopping but have not finished) along TimeDimension??

Thx
Greg


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

Default Re: TimeSpan / Calculation within TimePeriod - 03-22-2005 , 11:15 PM






With a [Visits] cube, suppose there are 2 identically structured Time
dimensions like [StartTime] and [EndTime], also a [Customer] dimension.
Suppose [EndTime] is used as the reference Time dimension. Then the
number of customers in the Supermarket at the end of the selected
[EndTime] could be like:

Quote:
With Member [Measures].[CustomersVisiting] as
'Sum(Tail(Descendants([EndTime].CurrentMember, [EndTime].[Minutes])) as
[VisitTime],
Count(Filter(NonEmptyCrossJoin(
[StartTime].[Minutes].Members,
[EndTime].[Minutes].Members,
[Customer].[CustomerID].Members),
Rank([StartTime].CurrentMember, [StartTime].[Minutes].Members) <
Rank(LinkMember([VisitTime].Item(0), [StartTime]),
[StartTime].[Minutes].Members) And
Rank([EndTime].CurrentMember, [EndTime].[Minutes].Members) >
Rank([VisitTime].Item(0), [EndTime].[Minutes].Members))))'
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

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