I have an RDL template which contains of several parameters. They are all optional and marked:
It is important that they are optional since sometimes the address does not contain AddressLine3 (or in fact AddressLine1 or AddressLine2, or even PostCode):
They are all dropped together in one textbox area, and it all works well, but the problem is if I don't pass one of the optional params (AddressLIne2 in the example below) - an empty line is preserved in the report:
Any ideas on how to make that empty line disappear?
The easiest way to do this is to replace the list of 5 parameters with a single expression. Something like this.
=
Parameters!FullName.Value & IIF(IsNothing(Parameters!FullName.Value), Nothing, vbcrlf) &
Parameters!AddressLine1.Value & IIF(IsNothing(Parameters!AddressLine1.Value), Nothing, vbcrlf) &
Parameters!AddressLine2.Value & IIF(IsNothing(Parameters!AddressLine2.Value), Nothing, vbcrlf) &
Parameters!AddressLine3.Value & IIF(IsNothing(Parameters!AddressLine3.Value), Nothing, vbcrlf) &
Parameters!PostCode.Value
This simply concatenates each parameter value with a new line added only if the parameter was not empty.
Demo data
The following shows the same principle applied to some address data from the sample AdventureWorks database
The report shows all address fields for illustration