Using the Reporting Database and Excel – Part 1

I am not sure if this is a programmability post, but there have been many requests to do a post on writing a report in Excel that collects data from the reporting database. Since this will involve SQL and many developers who write code against Project Server will also need to write reports; this may be useful to the developer community. I am going to break this into two posts because it is fairly long and there is a logical break. In the first post, we will create the SQL query to retrieve the data from the reporting database. In the second post, I will describe the process of using the query in Excel to write reports.

Before we begin, it should be known that there is a dedicated reporting database in Project Server 2007. This database is separate from the working and publish database that is heavily used by Project Professional and Project Server. Every time a project is published, or resource is updated, the data is pushed to the reporting database. The reporting database provides a supported interface for gathering project data via SQL queries. This reporting database has been setup to easily create reports.

Someone posted that they wanted a report that showed the assigned work for each resource, grouped by project and then by month. This will allow project managers to better understand the allocation of resources by month. I will try my best writing the query for this, but I shell add the warning that this has not been tested. If you find a mistake, or a better way of writing the query, please post it as a comment.

To begin, we need to write a SQL query against the reporting database to get at the data we need. I wrote the SQL query in stages. The first step was to get the assignment data from the projects. To do that, I wrote the following query:

SELECT

base.ResourceUID as‘Resource’,

assn.TimeByDay as‘Day’,

assn.AssignmentWork as‘Assigned’

FROM

MSP_EPMAssignmentByDay_UserViewAS assn

INNERJOIN MSP_EPMAssignment_UserView AS base

ON(assn.AssignmentUid= base.AssignmentUID)

This gives us all the assignments for each resource by name. We will also want the project name that the assignment is coming from. To do this, we will have to do another join on the MSP_EmpProject_UserView:

SELECT

base.ResourceUID as‘Resource’,

assn.TimeByDay as‘Day’,

assn.AssignmentWork as‘Assigned’,

ProjectName

FROM

MSP_EPMAssignmentByDay_UserViewAS assn

INNERJOIN MSP_EPMAssignment_UserView AS base

ON(assn.AssignmentUid= base.AssignmentUID)

INNERJOIN MSP_EpmProject_UserView

ON base.ProjectUID = MSP_EpmProject_UserView.ProjectUID

Now we have all the assignment data for each resource. For this report we will also want to capture assignments outside of a project. An example of this would be vacation time. To get at this information, we are going to query the Timesheet tables in the reporting database.

Now we have all the assignments. The next step is to combine the two queries. To do this, I used the union statement. You will notice that in the timesheet query we do not have a project name in the select. We are going to add the project name to the select by adding ‘None Project Time’as ProjectName to the select statement. Here are the combined queries: