1

我在 ssrs 中有一个这样的矩阵:

+--------------------+-------------------------+
|                    | Date                    |
+                    +----------+--------------+
|                    | Quantity | All Quantity |
+----------+---------+----------+--------------+
| Employee | Total   |          |              |
+          +---------+----------+--------------+
|          | Product |          |              |
+----------+---------+----------+--------------+

在这个表中Employee是一个Row group并且Product是一个孩子row groupDate是一个column group。在Quantity字段中,我有来自我的数据库的数字。在All Quantity列中,我需要Quantity在这个Date group. 但是使用我的表达式,它All Quantity使用来自 all 的数据进行计算Date groups

我的意思是,对于日期“2012-07-13”,所有数量应该是 1000,对于日期“2012-06-12”,它应该是 500。但不是这样,在两个日期都显示 1500。我应该如何解决这个问题?

我的表达在这里:

Sum(Fields!Quantity.Value, "Employee")

数据集如下所示:

Employee1   Product1    200 2012-01
Employee1   Product1    500 2012-02
Employee1   Product1    900 2012-03
Employee1   Product2    300 2012-01
Employee1   Product2    500 2012-02
Employee1   Product2    40  2012-03
Employee2   Product1    450 2012-01
Employee2   Product1    50  2012-02
Employee2   Product1    30  2012-03
Employee2   Product2    0   2012-01
Employee2   Product2    50  2012-02
Employee2   Product2    120 2012-03

这是我拥有什么、得到什么以及需要什么的一个例子。

//IF I USE Sum(Fields!Quantity.Value)
                    Date1                       Date2
                    Quantity    All Quantity    Quantity    All Quantity
Employee1   Total   590         -               190         -
                    100         100             50          50
                    200         100             50          50
                    150         150             40          40
                    50          50              30          30
                    90          50              20          20

//IF I USE Sum(Fields!Quantity.Value, "Employee")
                    Date1                       Date2
                    Quantity    All Quantity    Quantity    All Quantity
Employee1   Total   590         -               190         -
                    100         780             50          780
                    200         780             50          780
                    150         780             40          780
                    50          780             30          780
                    90          780             20          780

//I NEED TO GET
                    Date1                       Date2
                    Quantity    All Quantity    Quantity    All Quantity
Employee1   Total   590         -               190         -
                    100         590             50          190
                    200         590             50          190
                    150         590             40          190
                    50          590             30          190
                    90          590             20          190
4

1 回答 1

1

如果您可以在 SQL 中执行操作,它总是比在 RDL 中更快,但是,至少有一种方法可以在报告中执行。使用上面的第二个选项 Sum(Fields!Quantity.Value, "Employee"):

在我在下面指出的单元格上*,给它一个名字。它将是 textbox11 之类的,称为 EmployeeTotal。在我用插入符号^标记的单元格中,输入此表达式

=ReportItems!EmployeeTotal.Value

然后你会得到你想要的(见附图)。1

                    Date1                       Date2
                    Quantity    All Quantity    Quantity    All Quantity
Employee1   Total   590*         -              190         -
                    100         590^            50          190
                    200         590^            50          190
                    150         590^            40          190
                    50          590^            30          190
                    90          590             20          190

下次,如果您提供与您提供的要显示的内容相匹配的数据集示例,我们将更容易为您提供帮助。

例如,在我跑来测试这个的模型中,我使用这个查询来创建我认为是你真正的数据集:

![SELECT        'Employee1' AS Employee, 'Product1' AS Product, 100 AS Quantity, '2012-01' AS Date
UNION ALL
SELECT        'Employee1' AS Employee, 'Product2' AS Product, 200 AS Quantity, '2012-01' AS Date
UNION ALL
SELECT        'Employee1' AS Employee, 'Product3' AS Product, 150 AS Quantity, '2012-01' AS Date
UNION ALL
SELECT        'Employee1' AS Employee, 'Product4' AS Product, 50 AS Quantity, '2012-01' AS Date
UNION ALL
SELECT        'Employee1' AS Employee, 'Product5' AS Product, 90 AS Quantity, '2012-01' AS Date
UNION ALL
SELECT        'Employee1' AS Employee, 'Product1' AS Product, 50 AS Quantity, '2012-02' AS Date
UNION ALL
SELECT        'Employee1' AS Employee, 'Product2' AS Product, 50 AS Quantity, '2012-02' AS Date
UNION ALL
SELECT        'Employee1' AS Employee, 'Product3' AS Product, 40 AS Quantity, '2012-02' AS Date
UNION ALL
SELECT        'Employee1' AS Employee, 'Product4' AS Product, 30 AS Quantity, '2012-02' AS Date
UNION ALL
SELECT        'Employee1' AS Employee, 'Product5' AS Product, 20 AS Quantity, '2012-02' AS Date
于 2012-10-11T04:21:05.863 回答