I apologize up front for the length of this post, but I am relatively new to SSAS and have been struggling recently with trying to pull data from
a cube based on different times zones, so I wanted to include lots of detail in hopes that someone can help me get past what I believe is one last stubborn issue.
I think that I am almost there, but seem to have a problem with the actual data being returned from the cube.
I have created my cube based on this article
http://dbaspot.com/sqlserver-olap/393157-time-dimension-time-zones.html
Here is how I have things setup
I have a DimDateTime table that has a primary key as follows
DW_DateTimeKey bigint
Primary key data in the DimDateTime table is a combination of Year+Month+Day + '1' + Hour + Minute, for example
DW_DateTimeKey
2014042211451
2014042211452
2014042211453
etc...
Next, I have a table called MetaTimeZones with the following structure
PK TimeZoneId varchar(255)
Name varchar(255)
Display Name varchar(255)
Active bit
The active records in MetaTimeZones are shown below
TimeZoneId
Name Display Name
Active
Central Standard Time Central Standard Time
(UTC-06:00) Central Time (US & Canada) 1
Eastern Standard Time Eastern Standard Time
(UTC-05:00) Central Time (US & Canada) 1
UTC
Coordinated Universal Time (UTC) Coordinated Universal Time 1
Next, I have a table called FactSession with the following simplified structure
PK DW_FactSessionKey int
StartDW_DateTimeKey bigint
TalkTime
int
WasIvrAbandon tinyint
And a sample of the simplified FactSession data is shown below. Note that all data in the StartDW_DateTimeKey field is UTC based
![]()
Finally, to tie everything together, I have created a 'bridge' fact table called MetaNewTimeZoneAdjustments that has the following structure
PK UTCDW_DateTimeKey bigint
PK TimeZoneId
varchar(255)
LocalDW_DateTimeKey bigint
For testing purposes, I have only placed a few records into MetaNewTimeZoneAdjustments as shown below
![]()
In SSAS I have the DataSource View relationships setup as follows
- FactSession.StartDW_DateTimeKey -> MetaNewTimeZoneAdjustments.UTCDW_DateTimeKey
- MetaNewTimeZoneAdjustments.TimeZoneId -> MetaTimeZones.TimeZoneId
- MetaNewTimeZoneAdjustments.UTCDW_DateTimeKey -> DimDateTime.DW_DateTimeKey
- MetaNewTimeZoneAdjustments.LocalDW_DateTimeKey-> DimDateTime.DW_DateTimeKey
I created a cube called 'FactSession' based on the 'FactSession' table.
Next, I created an intermediate measure group called 'UTCToLocal'(with just the default row count measure) based on the 'MetaNewTimeZoneAdjustments'
table as shown below
Next, I created a Dimension called 'Dim Date Time' based on the 'DimDateTime' table, and added 2 roles of the 'Dim Date Time' dimension to
the cube, one named 'UTCTime' and the other named 'LocalTime' as shown below
Next I created a 'Meta Time Zones' dimension based on the 'MetaTimeZones' table. The key for the 'Meta Time Zones' dimension is 'TimeZoneId'. I removed
the 'All' member by setting 'IsAgregatable' to false and made the default member 'UTC'. The 'Meta Time Zones' dimension was then added to the cube as shown below
Next, the 'Dimension Useage' relationships for the cube were setup as follows
LocalTime - UTCToLocal
- Relationship Type: regular
- Granularity Attribute: DW Date Time Key
- Dimension Table: DimDateTime
- Measure Group Table: MetaNewTimeZoneAdjustments
- Dimension Column: DW_DateTimeKey
- Measure Group Column: LocalDW_DateTimeKey
UTCTime - UTCToLocal
- Relationship Type: regular
- Granularity Attribute: DW Date Time Key
- Dimension Table: DimDateTime
- Measure Group Table: MetaNewTimeZoneAdjustments
- Dimension Column: DW_DateTimeKey
- Measure Group Column: UTCDW_DateTimeKey
UTCTime - FactSession
- Relationship Type: regular
- Granularity Attribute: DW Date Time Key
- Dimension Table: DimDateTime
- Measure Group Table: FactSession
- Dimension Column: DW_DateTimeKey
- Measure Group Column: StartDW_DateTimeKey
LocalTime - FactSession
- Relationship Type: many-to-many
- Dimension Table: DimDateTime
- Intermediate Measure Group: UTCToLocal
Finally I created a Dimension called ‘Meta New Time Zone Adjustments’ based on the ‘MetaNewTimeZoneAdjustments’ table and added it to the cube,
the fields here probably need a little explanation…
- DW Date Time Key = DimDateTime.DW_DateTimeKey
- Local DW Date Time Key = MetaNewTimeZoneAdjustments.LocalDW_DateTimeKey
- Time Zone Id = MetaTimeZones.TimeZoneId
- Time Zone Id 1 = MetaNewTimeZoneAdjustments.TimeZoneId
- UTC DW Date Time Key = MetaNewTimeZoneAdjustments.UTCDW_DateTimeKey
After everything was setup I deployed\processed the cube and ran the following MDX
SELECT
{
[Measures].[Talk Time],
[Measures].[Was Ivr Abandon]
}ONCOLUMNS,
NONEMPTY
{(
[Meta New Time Zone Adjustments].[Local DW Date Time Key].&[2014042211145] : [Meta New Time Zone Adjustments].[Local DW Date Time Key].&[2014042211957]
)}ONROWS
FROM Sessions
WHEREFilter([Meta New Time Zone Adjustments].[Time Zone Id 1].ALLMEMBERS, Instr([Meta New Time Zone Adjustments].[Time Zone Id 1].CurrentMember.Properties('Member_Caption'),'Central Standard Time' ) > 0)
The results are shown below
Talk Time Was
Ivr Abandon
2014042211455 22932361 91977
2014042211457 22932361 91977
Changing the time zone from ‘Central Standard Time’ to ‘Eastern Standard Time’ gives the following results
SELECT
{
[Measures].[Talk Time],
[Measures].[Was Ivr Abandon]
}ONCOLUMNS,
NONEMPTY
{(
[Meta New Time Zone Adjustments].[Local DW Date Time Key].&[2014042211145] : [Meta New Time Zone Adjustments].[Local DW Date Time Key].&[2014042211957]
)}ONROWS
FROM Sessions
WHEREFilter([Meta New Time Zone Adjustments].[Time Zone Id 1].ALLMEMBERS, Instr([Meta New Time Zone Adjustments].[Time Zone Id 1].CurrentMember.Properties('Member_Caption'),'Eastern Standard Time' ) > 0)
Talk Time Was Ivr Abandon
2014042211555 22932361 91977
2014042211557 22932361 91977
And changing the time zone to ‘UTC’ gives the following results
SELECT
{
[Measures].[Talk Time],
[Measures].[Was Ivr Abandon]
}ONCOLUMNS,
NONEMPTY
{(
[Meta New Time Zone Adjustments].[Local DW Date Time Key].&[2014042211145] : [Meta New Time Zone Adjustments].[Local DW Date Time Key].&[2014042211957]
)}ONROWS
FROM Sessions
WHEREFilter([Meta New Time Zone Adjustments].[Time Zone Id 1].ALLMEMBERS, Instr([Meta New Time Zone Adjustments].[Time Zone Id 1].CurrentMember.Properties('Member_Caption'),'UTC' ) > 0)
Talk Time Was Ivr Abandon
2014042211955 22932361
91977
2014042211957 22932361
91977
So the adjusting of the Time Zone gives different times as I had hoped for, but there is one glaring problem.
The problem is that the values returned from the Fact Session table are not correct. ‘22932361’ is actually the sum of the ‘Talk Time’ column for
all of the records in the ‘FasctSession’ table. Similarily ‘91977’ is the sum of the ‘WasIvrAbandon’ column for all of the records in the ‘FactSession’ table.
The correct results for ‘Central Stand Time’ should be
Talk Time
Was Ivr Abandon
2014042211455 115223
255
2014042211457 177343
255
Can anyone please provide some insight into why I am getting summed data returned ?
Thanks for your time
Brian