2012-07-13 60 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