如何确定分层报告中可见子项的数量?

发布于 2024-08-05 21:57:52 字数 539 浏览 1 评论 0原文

我正在使用 SQL Server Reporting Services 2008 创建报告。此报告中的表格使用数据中的 ID 和 ParentID 字段显示分层数据。每个数据行都有一个 ID 字段和 ParentID 字段,其中 ParentID 指向其父行的 ID。

分层显示没有问题,但现在我想计算给定行的子项数。例如:

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

我可以使用以下表达式计算此计数:

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

但是,有时我想隐藏某些行,例如我想隐藏sub-sub A。在这种情况下,如何更改上述表达式,使其显示 sub B(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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

锦欢 2024-08-12 21:57:52

在报告中做到这一点似乎相当困难(如果不是不可能的话)。相反,我们将层次结构和子级数量的计算转移到存储过程中。 SP 执行所有必要的计算,报告仅显示从 SP 接收的内容,并且仅根据计算值应用简单的格式(如果需要)。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文