blogger counters

Thursday, March 05, 2009

TFS Report Issues with SQL Server 2008

Some of the reports that shipped with Team Foundation Server 2005 and 2008 run into problems when you attempt to run them on SQL Server 2008 Reporting Services. Here is an overview of of the problems and fixes for those problems. Most of these problems are a result of changes in how Analysis Services processes queries in 2008 vs 2005.

Complement and Except Errors

Several of the TFS reports show one of these errors when running under SQL 2008:

The set must have a single hierarchy to be used with the complement operator.

Two sets specified in the EXCEPT function have different dimensionality.

The reports that are affected are Scenario Details and Unplanned Work.

What does this mean? Basically, it means that the WHERE clause in the query is using the "-" operator to exclude a specific attribute from the query. For example, the Scenario Details reports includes the following inside the WHERE clause:

,STRTOSET( @AreaParam )

,STRTOSET( @IterationParam )

,STRTOMEMBER("[Team Project].[Team Project].[" + @Project + "]")

,-{STRTOMEMBER("[Work Item].[System_State].[System_State].[+@Proposed+]")}

 

The minus sign in front of the last line indicates that we want to filter out work items that are in the Proposed state. However, this doesn't work in SQL 2008. You'll notice that we're trying to exclude an a specific value without mentioning the other values.

The solution is to remove the exclusion from the WHERE clause and put it into the body of the query:

,STRTOSET( @AreaParam )

,STRTOSET( @IterationParam )

,EXCEPT(

    Descendants([Work Item].[System_State].[System_State])

    ,STRTOMEMBER("[Work Item].[System_State].[System_State].[+@Proposed+]")

)

 

The key here is that we need to include all states except for the Proposed state, which is what the Except function above does.

WHERE vs Sub Cube

Many of the reports were written using the WHERE clause to filter the results. For example, so the results would be filtered on a single team project instead of the entire cube. However, the behavior of the WHERE clause changed somewhat in SQL Server Analysis Services 2008. The simplest solution is to rewrite the WHERE clause as a sub-cube expression instead. Not only will this fix some of the problems, but it should also make reports run faster.

Old Version:

FROM [Team System]

WHERE

(

  STRTOMEMBER("[Team Project].[Team Project].[" + @Project + "]"),

  STRTOMEMBER("[Work Item].[System_WorkItemType].[" + @Bug + "]")

)

New Version:

FROM

(

  SELECT

    CrossJoin(

      STRTOMEMBER("[Team Project].[Team Project].[" + @Project + "]"),

      STRTOMEMBER("[Work Item].[System_WorkItemType].[" + @Bug + "]")

    ) ON COLUMNS

  FROM [Team System]

)

 

The WHERE clause above is applied after the rest of the MDX expression has been evaluated. But the second expression defines a subset of the cube that will be used to evaluate the rest of the expression. In other words, using a sub cube, you're restricting the set of cells to a smaller set before evaluating the query.

Extract Problems

Here is the error message you might see:

The Extract function was called with hierarchy 'System_Id' that does not exist in the set.

That's certainly not a very helpful error message. This message appears in the report called Bugs Found Without Corresponding Tests. The solution, as it turns out, is to use a sub-cube instead of a WHERE clause (described above).

Tuple Problem

In several of the reports, selecting all of the iterations produces the following error message:

The function expects a tuple expression for the argument. A tuple set expression was used.

More than 4,294,967,296 tuples

This error occurs with the following reports:

  • Bugs by Priority
  • Bugs Found Without Corresponding Tests
  • Issues and Blocked Work Items
  • Related Work Items
  • Requirement Details
  • Requirements Test History and Overview
  • Scenario Details
  • Triage
  • Unplanned Work

The solution to this problem is also to replace the WHERE clause at the end of the MDX query with a sub-cube expression, as described above.

SQL Reports and the IN Clause

The Load Test Summary report is a SQL report, and it contains an IN clause in the WHERE statement. This is used to allow multiple values to be selected and passed to the query. However, a change in behavior in SQL 2008 Reporting Services means that you'll see the following message when you have no values:

Incorrect syntax near ')'.

Here is why you see this message. The WHERE clause in the Load Test Summary report looks like this:

WHERE (Result.__ID IN (@ResultParam))
AND ([Test Result].[Result Record Count] = 1)

When there are no results passed into this query, Reporting Services 2008 simply removes @ResultParam, so you get something like "IN ()", and you get a syntax error, preventing this query from running.

The solution is to add an expression to the @ResultParam query parameter. This expression is evaluated in order to determine what is passed to the query. Here is what works:

=IIF(Parameters!ResultParam.Count > 0, Parameters!ResultParam.Value, "")

8 Comments:

At 8/24/09, 1:44 PM, Anonymous Anonymous said...

Your solution doesn't seem to work for me. Where exactly in the report parameter do you put the expression?
Sorry about the anonymous but I don't have any of the identities required.
Thanks in advance.

 
At 8/24/09, 1:54 PM, Anonymous Anonymous said...

My mistake. I put the expression in the DataSet->Properties corresponding Parameter Value and it works great.
Thanks for the tip!

 
At 10/24/09, 2:33 PM, Blogger mizhou said...

This post is very helpful!
I am wondering why there isn't a updated version of the sample reports.

 
At 10/24/09, 3:04 PM, Blogger mizhou said...

I also got a error message of "invalid object name 'Run result'" by executing report "Load Test Comparison.rdl"
and of "[rsFieldReference] The Group expression for the grouping ‘table1_Group2’ refers to the field ‘Work_Item_ID’. Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope" by executing report "Bugs Found Without Corresponding Tests.rdl"

 
At 10/24/09, 4:01 PM, Blogger mizhou said...

also, the datasourse TfsWarehouseExtension used in "Project Schedule.rdl" is not contained with the package.

 
At 6/1/11, 9:36 AM, Anonymous HKM said...

awesome, this was very helpful.

 
At 5/6/12, 8:20 AM, Anonymous Bill said...

Nice post which Here is an overview of of the problems and fixes for those problems. Most of these problems are a result of changes in how Analysis Services processes queries in 2008 vs 2005. Complement and Except Errors Several of the TFS reports show one of these errors when running under SQL 2008: The set must have a single hierarchy to be used with the complement operator. Thanks a lot for posting this article.

 
At 7/10/12, 9:15 AM, Blogger Lisa said...

I was not happy with sql 2008, the interface and other issues are not user friendly. Hierarchy Structure

 

Post a Comment

Links to this post:

Create a Link

<< Home