Search code examples
reporting-servicesssrs-2012ssrs-expression

How to concatenate IIF statements with vbcrlf?


How do I get this expression to work in SSRS? I'm trying to get the field value, and if it is blank then to skip it and go to the next one.

Any help is appreciated.

=IIF(IsNothing(Fields!street1.Value), "", Fields!street1.Value) & vbcrlf & And (IIF(IsNothing(Fields!street2.Value), "", Fields!street2.Value) & vbcrlf & And (IIF(IsNothing(Fields!street3.Value), "", Fields!street3.Value)))


INPUT:

Street 1: Text 1

Street 2: null

Street 3: Text 2


Desired OUTPUT:

Text 1

Text 2


Solution

  • You can put your VBCRLF inside your IIF statements:

    =IIF(IsNothing(Fields!street1.Value), "", Fields!street1.Value & vbcrlf) &  
     IIF(IsNothing(Fields!street2.Value), "", Fields!street2.Value & vbcrlf) &  
     IIF(IsNothing(Fields!street3.Value), "", Fields!street3.Value)