2016-06-09 78 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