Customizing Report Parameters for Team Foundation Server 2010
Very often you’ll want to change the default settings for parameters in a report, but Reporting Services doesn’t have a user interface that allows you to select parameters, and then save them for use again. There is a way to customize the set of parameter values without learning how to author reports, but it’s a little involved. In this post, I’ll cover the following:
- Changing the default values that are used to render a report
- Creating multiple views on the same report, each with different default parameters
About Report Parameters
First a little bit of background on report parameters. Many of the TFS 2010 reports read from the Analysis Services database (or cube) that, by default, is called Tfs_Analysis (it was called TfsWarehouse in previous releases). Since this is a cube, and not a relational warehouse, default parameter values will look a little odd. As an example, this is what the default value might look like when you want to select “Iteration 1” in the iteration parameter:
[Work Item].[Iteration Hierarchy].[Iteration1].&&
Yikes, you say, how are you supposed to figure that out?
I’m not going to get into the details of why this is so complicated. If you’re interested, I wrote an MSDN article for TFS 2008 that will give you some idea about how this works, although the details have changed since then.
But there is a tool you can use to get this information: SQL Server Management Studio, which you can install from the SQL Server DVD. Alternatively, you can use a free program called MDX Studio, which is what I’ll use here as an example.
Finding the Default Value
The first step is to launch MDX Studio and connect to the TFS cube. You might need to find out the server and database from your TFS administrator, and also have them grant you read access (they need to add you to the TfsWarehouseDataReader role).
Finding an Iteration Value
- Launch MDX Studio, type the name of the Analysis Services machine into the Connect to Analysis Services dialog box, and then click on the Connect button. You should see a display something like this:
- In the Metadata section, scroll down so you can see Work Item and expand that item.
- Expand the Work Item.Iteration Hierarchy node.
- Expand the (All) and then All nodes, and then the collection node that contains your team project.
- Expand the node that contains your team project. You should see something like this:
- Finally, drag the iteration node (Iteration 1 in this example) into the Query area:
You can now copy this “ID” and use it in the following steps.
Setting Parameter Defaults
You’ll be using Report Manager to make these changes:
- Right click on the Reports node of your team project inside Visual Studio and select Show Report Site…:
- Click on the Properties tab at the top of the report:
- Click on the Parameters link:
At this point you’ll see a list of parameters, which should look something like this:
To change the default iteration, for example, you would paste the value you got from the previous step into the text box circled in red above, and then click on the Apply button.
Multiple Parameter Settings – Linked Reports
There are times where you’ll want to have several versions of the report, each with different parameter values. Reporting Services has a feature called Linked Reports that allows you to essentially create sets of parameters that will be applied to a single copy of the report, but appear as a new report.
Here is how you create a linked report:
- Click on the Properties tab for the report (just like in the previous section)
- Click on the Create Linked Report button on the Properties page
- Type in the name you want to use for this new linked report, and then click on the OK button
- Click on the Properties tab of this new linked report
- Click on the Parameters link on the left side to customize the parameter values that will be used for the linked report, and click on the Apply button to accept the new default values