计算总计时忽略SSRS列组

时间:2012-07-13 12:50:25

标签: reporting-services

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

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

在此表中EmployeeRow groupProduct是孩子row groupDatecolumn group。在Quantity字段中,我有来自我的数据库的数字。在All Quantity列中,我需要在此Quantity中拥有Date group的总金额。但是使用我的表达式,它会使用来自所有All Quantity的数据来计算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

1 个答案:

答案 0 :(得分: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

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

e.g。在我试运行的模型中,我用这个查询来创建我认为真正的数据集:

![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