[reporting-services] Line break in SSRS expression

I'm having trouble adding a line break in SSRS 2008.

I've tried all of these different ways but nothing is doing it.

"+ chr(10) +" , "& chr(10) &" , "& chr(13) & chr(10) &" , "& vbcrlf &" , "+ vbcrlf +" , "Environment.NewLine"

Here's my textbox expression:

=IIF(First(Fields!VCHTYPE.Value, "Dataset1")="C","This is a huge paragrpah of text." +
vbcrlf + "separated by line feeds at each paragraph." +
vbcrlf + vbcrlf + "I want to separate the paragraphs." +
vbcrlf + vbcrlf + "Its not working though."
, "This is the second huge paragraph of text." +
vbcrlf + "separated by line feeds at each paragraph." +
vbcrlf + vbcrlf + "I want to separate the paragraphs." +
vbcrlf + vbcrlf + "Its not working though." )

This question is related to reporting-services ssrs-2008 newline iif

The answer is


If your placeholder is in html enabled mode then "<br />" will work as a newline


UseEnvironment.NewLine instead of vbcrlf


This works for me:

(In Visual Studio)

  1. Open the .rdl file in Designer (right-click on file in Solution Explorer > View Designer)
  2. Right-click on the Textbox you are working with, choose Expression
  3. In the Set expression for: Value box enter your expression like:

    ="first line of text. Param1 value: " & Parameters!Param1.Value & Environment.NewLine() 
    & "second line of text. Field value: " & Fields!Field1.Value & Environment.NewLine() 
    & "third line of text."
    

In my case, Environment.NewLine was working fine while previewing the report in Visual Studio. But when I tried to publish the rdl to Dynamics 365 CE, I received the error "The report server has RDLSandboxing enabled and the Value expression for the text box 'Textbox10' contains a reference to a type, namespace, or member 'Environment' that is not allowed."

So I had to replace Environment.NewLine with vbcrlf.


Use the vbcrlf for new line in SSSR. e.g.

= First(Fields!SAPName.Value, "DataSet1") & vbcrlf & First(Fields!SAPStreet.Value, "DataSet1") & vbcrlf & First(Fields!SAPCityPostal.Value, "DataSet1") & vbcrlf & First(Fields!SAPCountry.Value, "DataSet1") 

You Can Use This One

="Line 1" & "<br>" & "Line 2"

I've always had luck with the Chr(10) & Chr(13) - I have provided a sample below. This is an expression for an address text box I have in a report.

=Iif(Fields!GUAR_STREET_2.Value <> "",Fields!GUAR_STREET.Value & Chr(10) & Chr(13) & LTrim(Fields!GUAR_STREET_2.Value),Fields!GUAR_STREET.Value)

Also, if you are building a string you need to concatenate stuff together with an & not a + Here is what I think your example should look like

    =IIF(First(Fields!VCHTYPE.Value, "Dataset1")="C","This is a huge paragrpah of text." &
Chr(10) & Chr(13) & "separated by line feeds at each paragraph." &
Chr(10) & Chr(13) & Chr(10) & Chr(13) & "I want to separate the paragraphs." &
Chr(10) & Chr(13) &  Chr(10) & Chr(13) & "Its not working though."
, "This is the second huge paragraph of text." &
Chr(10) & Chr(13) & "separated by line feeds at each paragraph." &
Chr(10) & Chr(13) & Chr(10) & Chr(13) & "I want to separate the paragraphs." &
Chr(10) & Chr(13) & Chr(10) & Chr(13) & "Its not working though." )

You should NOT quote your Environment.NewLine man. Try "Your Text" & Environment.NewLine.


In Order to implement Line Break in SSRS, there are 2 ways

  1. Setting HTML Markup Type
    Update the Markup Type of the placeholder to HTML and then make use of <br/> tag to introduce line break within the expression

="first line of text. Param1 value: " & Parameters!Param1.Value & "<br/>" & Parameters!Param1.Value

  1. Using Newline function
    Make use of Environment.NewLine() function to add line break within the expression.

="first line of text. Param1 value: " & Parameters!Param1.Value & Environment.NewLine() & Parameters!Param1.Value

Note:- Always remember to leave a space after every "&" (ampersand) in order to evaluate the expression properly


It wasn't working for me either. vbcrlf and Environment.Newline() both had no effect. My problem was that the Placeholder Properties had a Markup type of HTML. When I changed it to None, it worked like a champ!


Examples related to reporting-services

How to use multiple conditions (With AND) in IIF expressions in ssrs Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0 Line break in SSRS expression SSRS expression to format two decimal places does not show zeros SSRS Expression for IF, THEN ELSE SSRS Conditional Formatting Switch or IIF SQL variable to hold list of integers Could not load file or assembly 'Microsoft.ReportViewer.WebForms' How do I format date and time on ssrs report? How do I display todays date on SSRS report?

Examples related to ssrs-2008

Line break in SSRS expression SSRS Conditional Formatting Switch or IIF Add column to SQL query results How do I format date and time on ssrs report? How do I display todays date on SSRS report? Cannot create a connection to data source Error (rsErrorOpeningConnection) in SSRS In SSRS, why do I get the error "item with same key has already been added" , when I'm making a new report? How to pass multiple values to single parameter in stored procedure Right pad a string with variable number of spaces SSRS Query execution failed for dataset

Examples related to newline

How can I insert a line break into a <Text> component in React Native? Print "\n" or newline characters as part of the output on terminal Using tr to replace newline with space How to write one new line in Bitbucket markdown? Line break in SSRS expression How to insert a new line in Linux shell script? Replace CRLF using powershell How to write new line character to a file in Java What is the newline character in the C language: \r or \n? How to print values separated by spaces instead of new lines in Python 2.7

Examples related to iif

SQL Server IIF vs CASE How to use multiple conditions (With AND) in IIF expressions in ssrs Line break in SSRS expression ORACLE IIF Statement JavaScript: IIF like statement