Sign In
EPM Development
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
Blog Home
Email Blog Author
Share this
RSS for posts
Atom
RSS for comments
Search
Advanced search options...
Search In:
Everything
Blogs
Forums
People
Groups
Places
Pages
Date range:
All Time
Last Year
Last 6 Months
Last 3 Months
Last Month
Last Week
Last Two Days
Tags
No tags have been created or used yet.
Archive
Archives
August 2009
(1)
February 2009
(1)
Add Time Hierarchy in Project Server 2007 Cubes
MSDN Blogs
>
EPM Development
>
Add Time Hierarchy in Project Server 2007 Cubes
Add Time Hierarchy in Project Server 2007 Cubes
Sean Day
28 Feb 2009 10:53 AM
Comments
3
Many organizations have their own definitions of time. Project Server standard time dimension may not fit their needs. Don't worry, we can extend the cube by adding more time hierarchies.
In Analysis Service 2005, one dimension could have multiply hierarchies. Now we don't need to add time dimension but just add another time hierarchy. If you want to find information about adding time dimension in project server 2000, you may check another post:
http://netsleeper.spaces.live.com/blog/cns!2D6B305EBBD50AA5!127.entry
Another good thing in project server 2005 is that we can use event and managed code. We can write code on OnCubeProcessed event. This event occurs after project server processed OLAP cube. Since we are creating time hierarchy, we need to wait project server finishing creating time dimension.
Here, I am using Analysis Management Object API for Analysis Service 2005, which is similiar but a little different from old way. The following sample code is to create another time hierarchy that only have year, week and day. So that week will not split between months.
public override void OnCubeProcessed(PSContextInfo contextInfo, CubeAdminPostCubeProcessEventArgs e)
{
try
{
WriteMessage("Start Cube Extension");
// connect analysis service server
Server OLAPServer = new Server();
OLAPServer.Connect("Data Source=" + e.ServerName + ";Provider=msolap;");
WriteMessage("Analysis service server connected:" + e.ServerName);
// open EPM OLAP database
Database EPMOLAP = OLAPServer.Databases.FindByName(e.DbName);
if (EPMOLAP == null)
{
EventLog.WriteEntry(LogSource, "Database: " + e.DbName + " does not exist in Project Server 2007 cube.", EventLogEntryType.Error);
return;
}
WriteMessage("Start building new Time hirarchy");
// open Time dimension
Dimension dmnTime = EPMOLAP.Dimensions[TimeDimensionID];
if (dmnTime == null)
{
EventLog.WriteEntry(LogSource, "Time dimension does not exist.", EventLogEntryType.Error);
return;
}
// check if the custom hierarchy is already created
if (dmnTime.Hierarchies.FindByName(NewTimeDimensionName) != null)
{
EventLog.WriteEntry(LogSource, "New Time hierarchy has already been created by other process.", EventLogEntryType.Error);
return;
}
// create custom hierarchy in time dimension
Hierarchy NewTime = dmnTime.Hierarchies.Add(NewTimeDimensionName);
// find year, week, and day attribute in time dimension
DimensionAttribute atrYear = dmnTime.Attributes.FindByName(YearAttributeName);
if (atrYear == null)
{
EventLog.WriteEntry(LogSource, "Year attribute does not exist in Time dimension.", EventLogEntryType.Error);
return;
}
DimensionAttribute atrWeek = dmnTime.Attributes.FindByName(WeekAttributeName);
if (atrWeek == null)
{
EventLog.WriteEntry(LogSource, "Week attribute does not exist in Time dimension.", EventLogEntryType.Error);
return;
}
DimensionAttribute atrDay = dmnTime.Attributes.FindByName(DayAttributeName);
if (atrDay == null)
{
EventLog.WriteEntry(LogSource, "Day attribute does not exist in Time dimension.", EventLogEntryType.Error);
return;
}
// create level for year, week, and day in custom hierarchy
Level lvlYear = NewTime.Levels.Add(YearLevelName);
lvlYear.SourceAttributeID = atrYear.ID;
Level lvlWeek = NewTime.Levels.Add(WeekLevelName);
lvlWeek.SourceAttributeID = atrWeek.ID;
Level lvlDay = NewTime.Levels.Add(DayLevelName);
lvlDay.SourceAttributeID = atrDay.ID;
WriteMessage("Complete building hirarchy");
// save the changes to database.
dmnTime.Update();
WriteMessage("Complete Cube Extension");
}
catch (Exception ex)
{
EventLog.WriteEntry(LogSource, ex.ToString(), EventLogEntryType.Error);
}
}
3 Comments
Blog - Comment List MSDN TechNet
Comments
Loading...
Leave a Comment
Name
Comment
Please add 6 and 6 and type the answer here:
Post