Modifying the expression

  • Hi

    I have a SSRS expression like

    =Fields!internalPartnerName.Value & "

    " & Fields!addressLine1.Value & "

    " & Fields!addressLine2.Value & "

    " & Fields!addressLine3.Value & "

    " & Fields!zipCode.Value & "

    " & Fields!city.Value & "

    " & Fields!countryName.Value

    Here if addressLine2 & addressLine3 fields in database are empty, an empty space will be shown in the SSRS report.

    How to avoid that empty space, by modifying the expression?

  • Empty as in NULL or empty as in an empty string?

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • In both cases, ie. If DB field is NULL or DB field is empty, it shows an empty space in the report.

  • You can check for NULL values with the IsEmpty funtion. For empty strings you can simply check the length of the string. If it is 0, you don't need to add a space.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Please modify my code so that I can get the idea.

  • See answer

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Thanks for the help.

    This was the existing code which I wanted to change for two textboxes.

    =Fields!internalPartnerName.Value & "

    " & Fields!addressLine1.Value & "

    " & Fields!addressLine2.Value & "

    " & Fields!addressLine3.Value & "

    " & Fields!zipCode.Value & "

    " & Fields!city.Value & "

    " & Fields!countryName.Value

    = Fields!internalPartnerName.Value & VbCrLf &

    Fields!addressLine1.Value & VbCrLf &

    Fields!addressLine2.Value & VbCrLf &

    Fields!addressLine3.Value & VbCrLf &

    Fields!zipCode.Value & VbCrLf &

    Fields!city.Value & VbCrLf &

    Fields!countryName.Value

    I changed the code this way & it worked.

    =Fields!internalPartnerName.Value & "

    "

    & Fields!addressLine1.Value & "

    "

    & IIF(IsNothing(Fields!addressLine2.Value) OR Fields!addressLine2.Value = "", Nothing, Fields!addressLine2.Value & "

    ")

    & IIF(IsNothing(Fields!addressLine3.Value) OR Fields!addressLine3.Value = "", Nothing, Fields!addressLine3.Value & "

    ")

    & Fields!zipCode.Value & "

    "

    & Fields!city.Value & "

    "

    & Fields!countryName.Value

    =Fields!internalPartnerName.Value & VbCrLf & Fields!addressLine1.Value & VbCrLf & IIF(IsNothing(Fields!addressLine2.Value) OR Fields!addressLine2.Value = "", Nothing, Fields!addressLine2.Value & VbCrLf ) &

    IIF(IsNothing(Fields!addressLine3.Value) OR Fields!addressLine3.Value = "", Nothing, Fields!addressLine3.Value & VbCrLf ) &

    Fields!zipCode.Value & VbCrLf &

    Fields!city.Value & VbCrLf &

    Fields!countryName.Value

  • Just to be safe you should do the same for the other fields as well. I used to get caught but that all the time. Enough modifications so it works, then move to the next fire. Then a user leaves a different field blank, and I'm back fighting the same fire...

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply