SSRS Pivoting a column

夙愿已清 提交于 2019-12-30 03:14:03

问题


I current have this report layout

ProductNumberDescriptionPackTypeDimensionWeight
PN 1                      Desc PN1      InnerPack 1x1x1          1          
PN 1                      Desc PN1      SinglePack1x1x1.2      1.2       
PN 2                      Desc PN2      InnerPack 2x2x2          2          
PN 2                      Desc PN2      SinglePack2x2.2x2.2   2.3       
PN 3                      Desc PN3      BulkPack  3x3x3          3          

Now, my users want to pivot like this

                                                        InnerPack                  SinglePack                      BulkPack          
ProductNumberDescriptionDimensionWeightDimensionWeightDimensionWeight
PN 1                      Desc PN1      1x1x1         1          1x1x1.2       1.2                                         
PN 2                      Desc PN2      2x2x2         2          2x2.2x2.2    2.3                                         
PN 3                      Desc PN3                                                                     3x3x3          3            

How can this be done? I'm using MS VS2008.

Thanks

TL

P.S. Thanks to ManisHearth to give me an idea how to create a table in post.


回答1:


You can do this with a standard Matrix. Create a Matrix and add a a Row Group based on ProductNumber and a Column Group based on PackType. I also added a couple more rows to the Matrix to allow some more details in header. I had to split the column header cells to add the Dimension and Weight headers.

Add the detail values to the Matrix body - I removed the automatic Sum that was added to the Weight value, but that's not strictly necessary. It should look something like this in the designer:

One more thing to consider; your PackType groups aren't in alphabetical order, so I updated the Column Group sort expression for your required ordering. I used:

=Switch(Fields!PackType.Value = "InnerPack", 1
    , Fields!PackType.Value = "SinglePack", 2
    , Fields!PackType.Value = "BulkPack", 3)

Final result, matching your requirements:



来源:https://stackoverflow.com/questions/15036335/ssrs-pivoting-a-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!