1

在矩阵控件中,我按“大小”对列进行分组,然后按“颜色”分组。结果表如下所示:

默认分组

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

分组

子组中的值应显示在父组中相应值的上方。

4

1 回答 1

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我最终没有使用它。

因此,它让我大致了解了您在数据集中需要什么。

我将一个 Matrix 下药并按大小和颜色分组 ( =Fields!size.Value & Fields!color.Value)

I 然后插入一个组,并按 Size ( =Fields!size.Value)分组

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

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

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

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

由于无法合并文本框,我唯一无法做的就是将大小居中。

分组示例

于 2010-10-11T13:27:34.347 回答