[英]SSRS Matrix with multiple groups
I have a dataset which generates results in this.我有一个数据集,可以在此生成结果。
Parent | NodeName | Value | ID |
---------------------------------------------
AAA | Name | blah1 | 1 |
AAA | val | 1 | 1 |
BBB | tag | tag2 | 2 |
BBB | Name | blah2 | 2 |
BBB | val | 2 | 2 |
AAA | tag | tag1 | 1 |
CCC | Name | blah3 | 3 |
CCC | tag | tag3 | 3 |
CCC | val | 3 | 3 |
AAA | Name | blah4 | 4 |
AAA | tag | tag4 | 4 |
AAA | val | 4 | 4 |
I would like to group this我想把这个分组
AAA
-----------------------------------------
| Name | Val | Tag |
-----------------------------------------
| blah1 | 1 | tag1 |
| blah4 | 4 | tag4 |
BBB
-----------------------------------------
| Name | Val | Tag |
-----------------------------------------
| blah2 | 2 | tag2 |
CCC
-----------------------------------------
| Name | Val | Tag |
-----------------------------------------
| blah3 | 3 | tag3 |
I have tried some tricks from this link but still no luck.我从这个链接尝试了一些技巧,但仍然没有运气。 Thanks.
谢谢。 http://agilebi.com/jjames/2010/09/10/how-to-pivot-data-in-ssrs/
http://agilebi.com/jjames/2010/09/10/how-to-pivot-data-in-ssrs/
I tried what @jimmy8ball suggested in comments.我尝试了@jimmy8ball 在评论中的建议。 The design surface looked like
设计表面看起来像
The final result looks like最终结果看起来像
As I only have three groups AAA, BBB and CCC at the moment.因为我目前只有三个组AAA,BBB和CCC。 I have created three different datasets with filters to only include one group eg, AAA.
我使用过滤器创建了三个不同的数据集,只包含一组,例如 AAA。 The result looks like this.
结果看起来像这样。
I am not sure if it is the best way of doing.我不确定这是否是最好的做法。 Any suggestions welcome.
欢迎任何建议。
Yet another update based on @Jimmy8ball.另一个基于@Jimmy8ball 的更新。 I am unable to get it working still as per @Jimmy8ball response.
根据@Jimmy8ball 的回复,我无法让它继续工作。
My dataset result looks like this我的数据集结果如下所示
My design surface looks like this.我的设计表面看起来像这样。
My result as per @jimmy8ball response looks like this, the second set of values for AAA are missing.根据@jimmy8ball 响应,我的结果如下所示,缺少 AAA 的第二组值。 Any suggestions?
有什么建议吗?
One solution is to group by Parent, then ID for the Maxtix Rows, and NodeName for the columns (and Value for the values).一种解决方案是按 Parent 分组,然后是 Maxtix Rows 的 ID 和列的 NodeName(以及值的 Value)。 It groups the data in the way you need, but the format isn't exactly the same as what you wanted.
它以您需要的方式对数据进行分组,但格式与您想要的并不完全相同。
If you want to have the column headers repeat for each Parent, one way is to use an outer List or Tablix for the Grouping.如果您希望为每个父级重复列标题,一种方法是使用外部 List 或 Tablix 进行分组。
to update the previous answer, follow the below setup, I have tweaked the matrix to display the NodeName as the split for each Parent, just as before, remove any auto counts or sums要更新以前的答案,请按照以下设置,我已经调整了矩阵以将 NodeName 显示为每个父级的拆分,就像以前一样,删除任何自动计数或总和
using row number and partition by here helps maintain the grouping levels, here is the sql i have used在此处使用行号和分区有助于维护分组级别,这是我使用的 sql
select parent+'-'+convert(varchar,ROW_NUMBER() over(partition by parent, nodename order by id)) as parent, nodename, value, id
from dbo.test1 t
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.