In my cube, I've a date dimension and a time dimension. I would like to know how can I calculate the percentage of order count for a specific time?
I can get this.
| Hour | 11/6/06 | 11/7/06 |
| 9am | 60 | 10 |
| 10am | 80 | 10 |
| 11am | 60 | 20 |
But how can I get this.
| Hour | 11/6/06 | 11/7/06 |
| 9am | 30% | 25% |
| 10am | 40% | 25% |
| 11am | 30% | 50% |
I would like to use the calculation feature in available in the cube. How can I do this? Thanks!
Depends on whether the percentage is always based on the time hierarchy, regardless of which query axis it lies on, or is based on whichever hierarchy is on rows - Axis(1). In the former case, something like:
Member [Measures].[OrderFractionByTime] as
'[Measures].[Order Count]/
([Measures].[Order Count], [TimeOfDay].Parent)',
FORMAT_STRING = "Percent"
|||Hi Deepak,
Thanks for your reply but there are something that I don't understand. In your code, you use [TimeOfDay].Parent in the member calculation. However, in my own cube, the date dimension and time dimension are 2 separate dimensions. So, I don't expect my TimeOfDay.Parent will get the expected set.
The following is my Date and Time dimensions structure.
DimDate - The Date dimension is populated by extracting data from my OLTP.
Year
Month
DayOfMonth
Date
DayNameOfWeek
DimTime - The Time dimension is generated by cross join all the available hour, minute and second. (No. of records: 24 x 60 x 60)
Hour
Minute
Second
P.S. I'm quite new to BI and datawarehouse. If my Time hierarchy is not correct or using best practice, please let me know so that I can improve it.
Regards,
Alex|||
Hi Alex,
Are you using AS 2000 or AS 2005 - if it's AS 2000, then something like:
Member [Measures].[OrderFractionByTime] as
'[Measures].[Order Count]/
([Measures].[Order Count], [DimTime].Parent)',
FORMAT_STRING = "Percent"
|||Hi Deepak,
I'm using AS 2005. The problem that I don't understand what [DimTime].Parent is pointing to. The Time dimension and Date dimension doesn't have any direct relationship in my cube. Is there any design fault?
Regards,
Alex|||
Alex,
With AS 2005, the hierarchy should also be specified with [DimTime], so [DimTime].[TimeHierarchy].Parent points to the parent of the current [DimTime] member. For example, the parent of the hour "01" will be [DimTime].[TimeHierarchy].[All].
http://msdn2.microsoft.com/en-us/library/ms145513.aspx
>>
SQL Server 2005 Books Online
Parent (MDX)
Updated: 17 July 2006
Returns the parent of a member.
...
>>