Question

I would like to run MDX Queries on the TFS Warehouse Database. I would like to query about the code churn, code coverage, ... and many other metrics.

Is there an easy way of creating those MDX queries? How can I achieve this?

I want to run those queries in a C# application.

Your help is much appreciated !

Was it helpful?

Solution

Josh,

SQL Server Management Studio has a built in interface for creating MDX queries. It's fairly intuitive if you understand the MDX language. Note that you will be writing MDX queries against the TFS_analysis OLAP cube and not against the TFS_Warehouse relational database.

In SQL Server Management Studio go to Connect -> Analysis Services and enter the database server\instance name for the SQL Server Analysis Services instance that you have connected to your TFS application tier. There is only one OLAP cube for TFS, Tfs_Analysis. Click "New Query" and you'll get a blank tab (just like with a SQL query) and an interface which lets you drag-and-drop measures and dimensions into the query window

That being said, I don't know if this is the best approach to getting the information that you want. I didn't find that writing straight up MDX queries to be all that useful. (admittedly I am not an MDX guru though) A better approach would be to use the SQL Server Reporting Services instance that you have associated with TFS and write reports against the TFS cube. You can use Microsoft's report builder application to write MDX expressions (they call these "calculated values") and then add those to a report.

This article pretty much explains everything you need to know write reports against the TFS cube, except for how to write MDX. http://msdn.microsoft.com/en-us/library/ff730837.aspx#bkmk_tfscube

On the topic of MDX queries \ expressions... I recently worked with a consultant from Microsoft who was a developer on SSAS and he recommended the following books if you need to learn MDX. I found a copy of the first one and it's quite informative.

http://search.barnesandnoble.com/Fast-Track-to-MDX/Mark-Whitehorn/e/9781852336813

http://www.amazon.com/gp/product/0471748080?ie=UTF8&tag=inabsqseanse2-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0471748080

http://www.amazon.com/gp/product/1849681309/ref=as_li_tf_tl?ie=UTF8&tag=inabsqseanse2-20&linkCode=as2&camp=217153&creative=399701&creativeASIN=1849681309

One other, final option is to use Excel to connect to the TFS cube and use the "perspectives" which come out-of-the-box to get the data you're looking for. There's a "Build" perspective, a "Code Churn" perspective... This is about a million times easier but doesn't give you quite as much power over getting the data you are looking for.

Using Excel to connect to the TFS cube is documented here: http://msdn.microsoft.com/en-us/library/ms244699(v=vs.100).aspx

So, in summary...

  1. Connecting Excel to the TFS cube is easy, but gives you little flexibility
  2. Writing reports against the TFS cube is more difficult, but gives you more power to get the data you want.
  3. Pure MDX queries give you ultimate control over what you're pulling back, but they are rather difficult to understand and write.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top