2012-07-13 64 views
1

我有这样的SSRS矩阵:SSRS列组

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

在此表中EmployeeRow groupProduct是一个孩子row groupDatecolumn group。在Quantity字段中,我有来自我的数据库的数字。在All Quantity列中,我需要在此Date group中的总金额为Quantity。但使用我的表达式,它使用来自所有Date groups的数据计算All Quantity

我的意思是,对于日期“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 
+0

你可以添加一个样本数据集的问题的最后机会吗? – Jeroen 2012-07-13 13:58:07

+0

我刚添加它。这是非常简单的数据集。 – JNM 2012-07-16 04:30:28

+0

目前还不清楚“数量”和“所有数量”之间的区别是什么。尽管如此,我认为如果你的分组是正确的,那么简单的'Sum(Fields!Quantity.Value)'(不要指定任何分组)就应该做到这一点。 – Jeroen 2012-07-16 20:40:09

回答

1

如果你能在SQL做的事情,它总是会比RDL速度更快,但是,至少还有一个办法,你可以做到这一点的报告。 使用上述的第二个选项, 总和(场Quantity.Value,“雇员”!):

在我下面指出的*细胞,给它一个名字。它将是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