Echo Das
Echo Das

Reputation: 45

SSRS IIF equal to A else equal to B

+---------+------+------+
|  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    |
+---------+------+------+

So i need to SUM in my SSRS report records from Col1 when Col3 equal 'R', else all records with Col3 equal 'P'.

The expresion that i have at the moment:

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

Upvotes: 1

Views: 86

Answers (2)

Mohamed Azizi
Mohamed Azizi

Reputation: 162

try this:

=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))
)

if it doesn't work let me know so I could give another solutions :)

Upvotes: 0

Mazhar
Mazhar

Reputation: 3837

Use Switch

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

Upvotes: 1

Related Questions