views:

42

answers:

1

I am using SQL Server Reporting Services 2008 to create a report. A table in this report displays hierarchical data, using a ID and ParentID field in the data. Each data row has an ID field and a ParentID field, where the ParentID points to the ID of the row that is its parent.

Displaying this hierarchically is no problem, but now I want to count the number of sub-items of a given row. For example:

row A            (5)
  sub A          (0)
  sub B          (2)
    sub-sub A    (0)
    sub-sub B    (0)
  sub C          (0)

I can calculate this count using the following expression:

=Count(Fields!IDField.Value, "RowDetails", Recursive) - 1

However, sometimes I want to hide certain rows, e.g. I want to hide sub-sub A. How can I alter the above expression such that it will show a count of (1) for sub B in this case?

A: 

It appears to be quite hard (if not impossible) to do this in the report. Instead, we have shifted the calculation of the hierarchy and the number of children to a stored procedure. The SP does all the necessary calculations, the report simply displays what it receives from the SP and only applies simple formatting (if necessary) based on the calculated values.

Daan