3

我有一个数据集,它使用四种测试类型以及他们的主管和主管之上的主管来显示工人在各种技能上的分数。为了节省空间,下面的数据集示例仅适用于一名工作人员。这就是我的开始:

Director Supervisor Worker Test Skill Score
Doris Smith Jane Awe Lorina Marc Overall 1: Identifying Support 1
Doris Smith Jane Awe Lorina Marc Test A 1: Identifying Support 4
Doris Smith Jane Awe Lorina Marc Test B 1: Identifying Support 1
Doris Smith Jane Awe Lorina Marc Test C 1: Identifying Support 5
Doris Smith Jane Awe Lorina Marc Overall 2: Tracking the Sequence 3
Doris Smith Jane Awe Lorina Marc Test A 2: Tracking the Sequence 2
Doris Smith Jane Awe Lorina Marc Test B 2: Tracking the Sequence 5
Doris Smith Jane Awe Lorina Marc Test C 2: Tracking the Sequence 5
Doris Smith Jane Awe Lorina Marc Overall 3: Searching for Exceptions 3
Doris Smith Jane Awe Lorina Marc Test A 3: Searching for Exceptions 3
Doris Smith Jane Awe Lorina Marc Test B 3: Searching for Exceptions 3
Doris Smith Jane Awe Lorina Marc Test C 3: Searching for Exceptions 3

我使用表格向导或矩阵向导将其输入 SQL Server Reporting Services。我必须将技能列移到分数列上,所以技能现在是列。

行组:主管、主管、工人测试 列组:技能 值:分数

我明白了:

Director    Suprviser   Worker  Test    1: Identifying  Support     2: Tracking the Sequence    3: Searching for Exceptions
Doris Smith Jane Awe    Lorina Marc Overal  1   3   3
            Test A  4   2   3
            Test B  1   5   3
            Test C  5   5   3
        Al Vega Overal  5   5   3
            Test A  3   3   2
            Test B  2   4   4
            Test C  5   2   5
        David  Osorio   Overal  1   1   3
            Test A  2   4   2
            Test B  4   5   1
            Test C  2   3   2
    Katie Lewis Ally McIntosh   Overal  1   2   3
            Test A  5   3   4
            Test B  3   3   2
            Test C  1   3   2
        Christina Gooderd   Overal  2   2   1
            Test A  4   4   1
            Test B  5   5   4
            Test C  2   5   4

我需要在每个单元格中都有一个值,因此需要为每个组重复这些值。所以,我想要的应该是这样的:

Director    Suprviser   Worker  Test    1: Identifying  Support     2: Tracking the Sequence    3: Searching for Exceptions
Doris Smith Jane Awe    Lorina Marc Overal  1   3   3
Doris Smith Jane Awe    Lorina Marc Test A  4   2   3
Doris Smith Jane Awe    Lorina Marc Test B  1   5   3
Doris Smith Jane Awe    Lorina Marc Test C  5   5   3
Doris Smith Jane Awe    Al Vega Overal  5   5   3
Doris Smith Jane Awe    Al Vega Test A  3   3   2
Doris Smith Jane Awe    Al Vega Test B  2   4   4
Doris Smith Jane Awe    Al Vega Test C  5   2   5
Doris Smith Jane Awe    David  Osorio   Overal  1   1   3
Doris Smith Jane Awe    David  Osorio   Test A  2   4   2
Doris Smith Jane Awe    David  Osorio   Test B  4   5   1
Doris Smith Jane Awe    David  Osorio   Test C  2   3   2
Doris Smith Katie Lewis Ally McIntosh   Overal  1   2   3
Doris Smith Katie Lewis Ally McIntosh   Test A  5   3   4
Doris Smith Katie Lewis Ally McIntosh   Test B  3   3   2
Doris Smith Katie Lewis Ally McIntosh   Test C  1   3   2
Doris Smith Katie Lewis Christina Gooderd   Overal  2   2   1
Doris Smith Katie Lewis Christina Gooderd   Test A  4   4   1
Doris Smith Katie Lewis Christina Gooderd   Test B  5   5   4
Doris Smith Katie Lewis Christina Gooderd   Test C  2   5   4

我要修复/更改/修改什么,以便我可以在每个单元格中填写一个值?

4

2 回答 2

10

如您所见,SSRS 以不同方式处理行标题单元格,即将它们延伸到任何子组。

您的报告可能看起来有点像这样:

在此处输入图像描述

我已经突出显示了分隔报告区域的虚线。此示例报告与您的示例具有相同的问题:

在此处输入图像描述

为了解决这个问题,需要将各种行组值从行标题区域移动到主报表区域。

首先,删除左边的四行——当提示时选择Delete columns only

在此处输入图像描述

您应该只剩下技能列。

右键单击并插入列 -> 外部组 - 左

在此处输入图像描述

继续使用Insert Column - Left添加列。

在此处输入图像描述

一旦你有足够的新列,添加各种分组值。报告应如下所示:

在此处输入图像描述

请注意,现在技能列和测试列之间没有虚线。

现在根据需要为每一行重复组值:

在此处输入图像描述

于 2013-07-07T12:30:47.013 回答
1

我有一个类似的问题,但是在一个矩阵中,当只有一个行组时,需要在详细信息组级别重复先前的值。为此,我使用了自定义代码。

例如,我的矩阵中有一个名为“Clusters”的列。行组字段是一个简单的日期字段。在我的数据集中,我有 Date、Clusters、ResourceType 作为字段。我有不同的资源类型值,因此我可以看到与给定资源类型关联的集群具有数据的日期。我的挑战来自我的数据集稀疏这一事实——对于给定的 ResourceType 值,并非所有日期都有值。在我的矩阵中,我最终得到的行在单元格中具有空白值,而基础数据集中没有相应的行。Previous 的使用效果不佳(许多其他示例)。

为了解决这个问题,我使用了自定义代码和哈希表,如下所示:

Private LastSeenValue as System.Collections.HashTable = New System.Collections.HashTable
' GetRowValue is used to fill in blank cells in the dynamic matrix with the nearest value above them in the same column.
' The data can contain multiple sets according to ResourceType field, and not all dates are present in all of these sets.
' This has the effect on the screen of having blank cells for each given date where there is no corresponding resource type.
' The requirement this function enables is that it allows filling in the blank cells with the nearest real value above.
' The SSRS PreviousRow function does not do this.
' Author:  DanRo, 1/8/2016
'
' Some behavior notes for developers who follow and seek to alter the function.
' The prototype for the GetRowValue function performs "null to zero" coercion as a result of return type.  This was done purposefully.
'  The Object type for the FieldVal inpute parameter allows null rows to be processed with the same type of coercion
'  on the incoming side.  
' This is report specific logic that takes advantage of the fact that all of data requiring this function is numeric.
Function GetRowValue(ByVal FieldName as String, ByVal FieldVal as Object, ByVal ResourceType as String) As Double

' TheKey variable allows this function to be used for any number of columns for any number of resource types.
Dim TheKey as String 

TheKey = "[" & FieldName & "][" & ResourceType & "]"

' See if a value was passed.  In SSRS, when the cell tries to render in the matrix, there 
' is no underlying data row for the column region, so a null (Nothing) gets passed by the runtime environment.
    If FieldVal is Nothing Then
       ' Coercion on the return type happens when the HashTable Item property returns Null if the lookup fails.
       '  If the lookup succeeds, the last value encountered (top to bottom) will be present.
    Return LastSeenValue(TheKey)
    End If

    ' now we know that a value was passed
    If (Not LastSeenValue.ContainsKey(TheKey))  Then
        LastSeenValue.Add(TheKey, FieldVal)
        Return FieldVal
    End If

    ' A value was passed and we have an old value. Update it
    LastSeenValue(TheKey) = FieldVal
    Return FieldVal

End Function

最后,在 Matrix Cell for Clusters 列中,我将表达式设置为:

=Code.GetRowValue("Clusters", Fields!Clusters.Value, ReportItems!ResourceType.Value)

这解决了问题。一个额外的好处是现在我在表格开头的空白行现在正确包含零(这对我来说是正确的)。一件棘手的事情是将 FieldVal 参数键入 Object 而不是 Integer(这是我的 Clusters 数据类型),因为您无法检查值类型是否存在。另一个指的是ReportItem!ResourceType.Value instead of Fields!ResourceType.Value因为 ResourceType 是我的列分组。最后,函数的返回类型选择将影响您的数据是否有小数点 - 因此选择 Double 可以让您处理整数和实数。必须对其进行修改以使此函数正确处理字符串。

之前,原始经验:

原创体验

之后,值现在在以前空白的地方重复:

值现在在以前空白的地方重复

于 2016-01-08T01:11:22.053 回答