SSRS 层次结构递归 parent - child 具有多个 parent

SSRS Hierarchy Recursive parent - child with multiple parent

您好,我需要有关 SSRS 设置的帮助,以便在层次结构报告中的多个 parent 中正确显示 children。

这就是我所做的。

 select * from PCA

这是 PCA table

Parent      Child
ASSY1       CHILD1    
ASSY1       CHILD2    
CHILD1      ACHILD1   
CHILD1      ACHILLD2  
ACHILD1     BCHILD1   
ACHILD1     BCHILD2   

这是报告数据集中的 CTE

 WITH tBOM AS(
 SELECT Parent,Child, 0 as BOMLevel from PCA A
 WHERE Parent='ASSY1'
 UNION ALL
 SELECT C.Parent, C.Child, BOMLevel+1 from PCA C
 INNER JOIN tBOM on tBOM.Child=C.Parent
 )
 SELECT row_number() over (Order by Parent), * FROM tBOM

这是 SSRS rdl 文件中的设置。和我运行时的报告有关。按 Child 分组,我将 递归 parent 设置为 parent。我还设置了组可见性,所以我得到加号来进行向下钻取和填充。一切看起来都不错。

左边距设置如下:

=20 * Level() & "pt"

UNTIL:我向 table 添加了一行。

Parent  Child
ASSY1       CHILD1    
ASSY1       CHILD2    
CHILD1      ACHILD1   
CHILD1      ACHILLD2  
ACHILD1     BCHILD1   
ACHILD1     BCHILD2   
**ACHILLD2      BCHILD2**   

我希望低于 ACHILLD2 但是没有:这就是我得到的

更多内容。如果我添加更多行来增加深度,结果将更加不正确。例如,如果我将 children 添加到 BCHILD2,

但是我得到的是:

阅读数小时的文章后。我得出的结论是 SSRS 无法实现我的最终目标。 伤心我知道。但它就是这样

https://connect.microsoft.com/SQLServer/feedback/details/724449/bug-found-when-using-the-ssrs-recursive-hierarchy-feature-with-multi-parent-relationships

Bug Found When using the SSRS Recursive Hierarchy Feature with Multi-Parent Relationships - by MichaelLee

Status : Closed as By Design By Design

The product team believes this item works according to its intended design.

A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Description

In a SSRS report, you can create a recursive hierarchy with drill down controls by following this article: http://msdn.microsoft.com/en-us/library/bb630438(v=SQL.100).aspx

However, it seems that this feature does not work correctly when a child has multiple parents. If a child has two parents, you would expect that a child is placed under each parent. Instead, the child is placed only under the parent that appears first in the SQL table. If you add an additional column to the tablix and set the expression to '=CountRows("RowGroupName",Recursive)', you'll notice that the total records for the child is 2. So for some reason both records are being placed below the first parent, even though one of the records has a different parentid.

Note that in my situation, the child and parent ids are of the type uniqueidentifier.

DETAILS Comments (2) | Workarounds (3) | Attachments (0) Sign in to post a comment. Posted by Ibrahim Achkar on 4/20/2012 at 6:10 AM Hello Michael, I also found this bug. Any update concerning a resolution from Microsoft. As for your workaround, do you suggest getting the data and setting it in a new temp table in a different (1-to-1 relationship) format. With the new table at hand, do we still need to use the parent grouping in SSRS or another method is required?

Your assistance is highly appreciated.

Thank you, Ibrahim Posted by Riccardo [MSFT] on 2/13/2012 at 5:34 PM Thanks for your feedback. We're resolving this bug as By Design because we associate each group with a single parent group. We don't associate a group with multiple parent groups (but feel free to create a Suggestion for this capability).

To further explain the expected behavior, we first group the data based on the GroupExpression, or the ChildID field in this case. Then we evaluate the Parent expression, in this case the ParentID field, for each group. Since we associate each group with a single parent group, we need a single value. When an expression that should return a single value refers to fields in a scope with multiple data rows - this case is just one example - the behavior is officially undefined, but in practice, it tends to behave like the First aggregate function, which takes the first data row in scope.

Riccardo Muti SQL Server Reporting Services

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a65bf4a4-e3b6-4c33-aa9e-6f7d7e4b7f5e/bill-of-materials-recursive-parent-report?forum=sqlreportingservices

Hi duanekae, Just to confirm, I never had an adequate solution using SSRS for this. I have ended up using a custom SQL function to do this. I would love the get it working in SSRS though as this would be a much easier solution. Wednesday, January 13, 2016 4:04 PM Quote Avatar of Alex Lush - Severn Unival Alex Lush - Severn Unival