如何确定分层报告中可见子项的数量?
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在报告中做到这一点似乎相当困难(如果不是不可能的话)。相反,我们将层次结构和子级数量的计算转移到存储过程中。 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.