2016-06-09 80 views
1

我試圖獲得列Max的值,即列AB,C的最大值。該行TGTotalGrand total(因爲行組),我只需要爲他們的最大值:獲取報表中計算列(總計)的最大()值

----------------------------- 
     A B C | Max 
----------------------------- 
     | 1 1 2 |  
----------------------------- 
     | 2 1 3 |  
------+---------------+------ 
    T | 3 2 5 | 5 
------+---------------+------ 
     | 2 5 1 |  
----------------------------- 
     | 1 2 1 |  
------+---------------+------ 
    T | 3 7 2 | 7 
------+---------------+------ 
    G | 6 9 7 | 9 
----------------------------- 

每當我試着用Max()功能的東西,我得到一個錯誤,如The expression of [...] uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in the headers and footers.

在MS Excel中,我只是在Max列中做MAX(A1:C1)。有沒有解決方案可以在rdlc中實現這一點?

我有搜索上面的錯誤,發現this answer,但第一個選項是不可能的,第二個選項..嗯,我真的不明白它,我不認爲它適用於Max。如果是這樣,你能解釋我應該在哪裏放置解決方法嗎?

我正在使用Visual Studio 2015和Microsoft.ReportViewer.WebForms v10.0.0.0。

回答

1

它需要把這個代碼在該領域 「最大」 行的 「T」 和 「G」 ..它應該工作..我還沒有tryed;)

If Sum(Fields!A.Value) >= Sum(Fields!B.Value) And Sum(Fields!A.Value) >= Sum(Fields!C.Value) Then 
    Sum(Fields!A.Value) 
Else if Sum(Fields!B.Value) >= Sum(Fields!A.Value) And Sum(Fields!B.Value) >= Sum(Fields!C.Value) Then 
    Sum(Fields!B.Value) 
Else 
    Sum(Fields!C.Value) 
End If 


更新 KevinM

IIf ( 
     Sum(Fields!A.Value) >= Sum(Fields!B.Value) And Sum(Fields!A.Value) >= Sum(Fields!C.Value) 
     , Sum(Fields!A.Value) 
     , ( 
     IIf (Sum(Fields!B.Value) >= Sum(Fields!A.Value) And Sum(Fields!B.Value) >= Sum(Fields!C.Value) 
     , Sum(Fields!B.Value) 
     , Sum(Fields!C.Value) 
    ) 
    ) 
的評論後,
+0

謝謝,但我不能在字段表達式中使用If語句,只有'IIf',它應該工作相同,但我實際上有六列(在這裏三個以保持示例簡單),並且字段表達式是真的大和無法維護... – KevinM

+0

這是真的..我不記得:) .. –

+0

這與小的變化一起工作:1)我刪除了'Sum(...)',因爲這些字段已經計算出來了,2)而不是'Fields!A.Value',這個字段引用是用'ReportItems!A.Value'創建的。謝謝。 – KevinM