2013-08-28 63 views
2

我有一個SSRS報告,在數據庫中有一列名爲Total_running_hours。 對於單個Cycle_number,有多條記錄,如同一行Cycle_numbe r,但不同Block_numbers,並且Total_running_hours字段中的值對於具有相同Cycle_number的所有行都是相同的。例如, 1對於所有4行,4個差異的循環數block_numbers包含相同的Total_running_hours在SSRS報告中發現組和總計條件時出錯

現在的問題是,在組頁腳,如果我把這個字段,則它會顯示Total_running_hours值只有一次是正確的,但我的最後一個要求是,

我需要得到這個字段的總和在報表頁腳中需要顯示彙總明智。無論單個Cycle_number有多少行,它只需要一次並顯示結果。

我以不同的方式嘗試像

=sum(ReportItems!textbox204.Value) // name of text box in Group footer 

Error: Report item expressions can only refer to other report items within the same grouping scope or a containing grouping scope.

=sum(Fields!total_running_hours.Value,Group_name) 

Error: The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing data region, or the name of a data set.

任何一個可以請幫我在爭取和集團智慧

預先感謝您。

回答

0

我找到了解決這個問題的辦法。

我們不能簡單地總和Total_Running_hours值,因爲這會給我們帶來重複和不正確的答案。我們無法對報告服務組進行求和,因爲它超出範圍 Reporting Services 2005中沒有SUM DISTINCT可用,因此我們無法通過這種方式獲取明確的值。

由於查詢可能不會返回特定的Cycle_Number類型,因此我們不能將其用作過濾器。

的溶液中發現的是()由Cycle_Number這樣

ROW_NUMBER劃分的窗口集OVER(PARTITION BY Cycle_Number ORDER BY Cycle_Number)內添加的行編號的列AS 'ROWNUMBER'

然後在報表的footer total列中,我們放置一個表達式,它只取第一行的值進行求和,並將該窗口集中的所有其他行轉換爲零。

= SUM(IIF(領域!RowNumber.Value = 1,場!Total_Running_hours.Value,0))

使用之後如果u發現任何錯誤文本像#錯誤

那就試試這個(IIF(Fields!RowNumber.Value = 1,CDbl(Fields!Total_Running_hours.Value),CDbl(0.0)))