SSRS IIF等于A等于B

时间:2017-11-24 09:35:53

标签: reporting-services visual-studio-2013

+---------+------+------+
|  Col1   | Col2 | Col3 |
+---------+------+------+
| 12,57   |  001 | P    |
| 23,08   |  002 | P    |
| -12,57  |  003 | R    |
| -23,08  |  004 | R    |
| 139,44  |  005 | P    |
| 163,99  |  006 | P    |
| -303,43 |  007 | P    |
+---------+------+------+

因此,当Col3等于' R'时,我需要在Col1的SSRS报告记录中使用SUM,否则所有记录与Col3等于' P'。

我现在的表达:

  

=总和(IIF(Fields!Col3.Value =" R",Fields!Col1.Value,0))

2 个答案:

答案 0 :(得分:1)

使用开关

=SUM(Switch(
       Fields!Col3.Value = "R", Fields!Col1.Value,
       Fields!Col3.Value = "P", Fields!Col1.Value
    )
)

答案 1 :(得分:0)

试试这个:

=IIf(
sum(IIf(Fields!Col3.Value Like "R",Sum(Fields!Col1.Value),0)),
sum(IIf(Fields!Col3.Value Like "P",Sum(Fields!Col1.Value),0))
)

如果它不起作用,请告诉我,以便我可以提供另一种解决方案:)