Nested iif with multiple conditions SSRS

jenhil34 picture jenhil34 · Mar 1, 2013 · Viewed 74.9k times · Source

I need to write a formula for a SSRS report. I am not for sure about the exact syntax, but it I am thinking it should be a nested iif but with multiple criteria, checking the value of the chart and division fields. At the end of the day if chart=110300 and division=100 then "Intercompany AP - USA" or if chart=110300 and division=200 then "Intercompany AP - RUS" other wise, then just display the chartname. Something like this but actually written correctly.

iif Fields!chart.Value="110300" and Fields!division.Value="100" then
Fields!chartname.Value="Intercompany AP - USA" if Fields!chart.Value="110300"
and Fields!division.Value="200" then Fields!chartname.Value=
"Intercompany AP - RUS" else Fields!chartname.Value

I greatly appreciate any help on this!

Answer

Tom Jenkin picture Tom Jenkin · Mar 2, 2013

You pretty much solved this one yourself! To write this in T-SQL you right click the Chart Name and change its value to the following expression:

IIF(Fields!chart.Value="110300" AND Fields!division.Value="100","Intercompany AP - USA",IIF(Fields!chart.Value="110300" AND Fields!division.Value="200","Intercompany AP - RUS","Default Chart Name")

See here for explanation on how the IIF function works

From the link you can see that it takes the following format, where commas are used instead of "Then" or "Else":

IIF ( boolean_expression, true_value, false_value )

So to breakdown the expression:

IIF(Fields!chart.Value="110300" AND Fields!division.Value="100",
    "Intercompany AP - USA",
     IIF(Fields!chart.Value="110300" AND Fields!division.Value="200",
        "Intercompany AP - RUS",
        "Default Chart Name"
     )
)