在矩阵控件中反转嵌套列组的标题行

时间:2010-10-11 11:47:02

标签: reporting-services ssrs-tablix

在矩阵控件中,我按“尺寸”分组列,然后按“颜色”分组。结果表如下所示:

default grouping

我需要反转标题行,因此表格如下所示:

grouping

来自子组的值应显示高于来自父组的相应值。

1 个答案:

答案 0 :(得分:0)

可能通过将“父组”设置为“大小”和“颜色”的组合分组,但只显示“颜色”,然后显示“子组/子组的大小”。

更新

好的,所以我创建了一个小数据集,我不确定数据集是否与你回来的一样,但也许它可以激发一些关于如何在SQL中操作数据以帮助获得你想要的东西的其他想法在报告中。

首先我刚刚创建了一堆SELECT ... UNION ALL语句,但经过一些玩弄后,我仍然无法获得所需的视觉输出/分组。所以这就是我使用的:

with CTE (Color, Size, CSGroup, Amt) As (
select 'Red' As color, 'Small' as size, 'RedSmall' as CSGroup, 1 as Amt union all
select 'Red' As color, 'Small' as size, 'RedSmall' as CSGroup, 1 as Amt union all
select 'Red' As color, 'Medium' as size,'RedMedium' as CSGroup, 1 as Amt union all
select 'Red' As color, 'Medium' as size, 'RedMedium' as CSGroup, 1 as Amt union all
select 'Red' As color, 'Medium' as size, 'RedMedium' as CSGroup, 1 as Amt union all
select 'Red' As color, 'Small' as size, 'RedSmall' as CSGroup, 1 as Amt union all

select 'Yellow' As color, 'Small' as size, 'YellowSmall' as CSGroup ,1 as Amt union all
select 'Yellow' As color, 'Small' as size, 'YellowSmall' as CSGroup ,1 as Amt union all
select 'Yellow' As color, 'Large' as size, 'YellowLarge' as CSGroup ,1 as Amt union all
select 'Yellow' As color, 'Large' as size, 'YellowLarge' as CSGroup ,1 as Amt union all
select 'Yellow' As color, 'Large' as size, 'YellowLarge' as CSGroup ,1 as Amt union all
select 'Yellow' As color, 'Medium' as size, 'YellowMedium' as CSGroup ,1 as Amt union all
select 'Yellow' As color, 'Medium' as size, 'YellowMedium' as CSGroup ,1 as Amt union all

select 'Blue' As color, 'Medium' as size, 'BlueMedium' as CSGroup, 1 as Amt union all
select 'Blue' As color, 'Medium' as size, 'BlueMedium' as CSGroup, 1 as Amt union all
select 'Blue' As color, 'Medium' as size, 'BlueMedium' as CSGroup, 1 as Amt union all
select 'Blue' As color, 'Small' as size, 'BlueSmall' as CSGroup, 1 as Amt union all
select 'Blue' As color, 'Large' as size, 'BlueLarge' as CSGroup, 1 as Amt union all
select 'Blue' As color, 'Large' as size, 'BlueLarge' as CSGroup, 1 as Amt union all

select 'Green' As color, 'Medium' as size, 'GreenMedium' as CSGroup, 1 as Amt union all
select 'Green' As color, 'Medium' as size, 'GreenMedium' as CSGroup, 1 as Amt union all
select 'Green' As color, 'Large' as size, 'GreenLarge' as CSGroup, 1 as Amt union all
select 'Green' As color, 'Large' as size, 'GreenLarge' as CSGroup, 1 as Amt union all
select 'Green' As color, 'Large' as size, 'GreenLarge' as CSGroup, 1 as Amt union all
select 'Green' As color, 'Small' as size, 'GreenSmall' as CSGroup, 1 as Amt union all
select 'Green' As color, 'Small' as size, 'GreenSmall' as CSGroup, 1 as Amt)
Select Color, Size, SUM(Amt) As Amount From CTE group by Color, Size

您可以忽略CSGroup我最终没有使用它。

因此,它给了我“数据集”中所需内容的“外观”。

我吸毒了一个矩阵并按照尺寸&颜色(=Fields!size.Value & Fields!color.Value

我然后插入一个组,并按大小(=Fields!size.Value

分组

在“顶部”列分组中,我有=Fields!color.Value

在第二列分组中,我有=First(Fields!Size.Value)

在数据文本框中,我有=Sum(Fields!Amount.Value)

然后,右键单击第二列分组并选中“隐藏重复项”框。然后我在下拉列表中选择了Dataset1

我唯一无法做的就是让尺寸居中,因为我无法合并文本框。

Grouping Example