Search code examples
reporting-servicesssrs-2008

IIF statement missing something


I'm way out of my element with SSRS Expressions. I'm hoping someone could lend me a hand.

I have 2 name fields:

  • ContactName
  • BusinessName

If ContactName is NOT NULL then only use the ContactName. However, if ContactName is NULL and BusinessName is NOT NULL then use the BusinessName.

I tried the following:

    =IIF(NOT
         Fields!ContactName.Value Is Nothing, 
         Fields!ContactName.Value, 
         Fields!BusinessName.Value
        )

However, it isn't picking up when I only have a BusinessName.

What do I need to do to also display the BusinessName when I only have a BusinessName?

Just as an update:

The answer was a combination of the IIF statement and a check to see if the value was also an empty string.


Solution

  • In SSRS, ISNOTHING is a function that requires an argument.

    Your expression just needs a little change to put your field in the argument:

     =IIF(NOT ISNOTHING(Fields!ContactName.Value), 
             Fields!ContactName.Value, 
             Fields!BusinessName.Value
            )