简体   繁体   中英

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/

I tried what @jimmy8ball suggested in comments. The design surface looked like设计面

The final result looks like最后结果。但有差距

As I only have three groups AAA, BBB and CCC at the moment. I have created three different datasets with filters to only include one group eg, 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. I am unable to get it working still as per @Jimmy8ball response.

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. 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). 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.

  • In your Matrix, grouping by ID for the rows and NodeName for the columns
  • Also create a List, that has Parent as it's row group. (Don't have page breaks between the instances of the group)
  • Put the Matrix into the List
  • Add a TextBox for the Parent value in the list, above the Matrix.

在此处输入图片说明

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

在此处输入图片说明

using row number and partition by here helps maintain the grouping levels, here is the sql i have used

select parent+'-'+convert(varchar,ROW_NUMBER() over(partition by parent,  nodename order by id)) as parent, nodename, value,  id
from dbo.test1 t

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM