Search code examples
sqlstored-proceduresreporting-servicesline-breaksssrs-2012

SSRS - Line break in Matrix cell


In a SSRS Matrix cell I want to be able to have a line break between each output given.

I have the following code in my MS SQL Server Stored Procedure which I then point my SSRS report to

SELECT Customer, Hostname, (QName + QHostname + Qtag + QSerial + QCategory + QType + QItem + QManu + QModel + QVersion) AS AdditionalInfo1 
FROM TableQ

At the moment in the AdditionalInfo1 cell when one of the options is returned they are separated by a comma

e.g.

QName, QHostname, Qtag.

Instead I would like them to be separated by a line break all within the same cell

e.g.

QName

QHostname

Qtag

I have tried putting + char(13) + between each Q... in AdditionalInfo1 but this didn't work.


Solution

  • For SSRS, you want to use Chr(10), not Chr(13). I've used this in expressions and as a Join delimiter argument and it produced the desired effect: line breaks within the textbox.

    Edit:

    Below is an expression that will include the fields with line breaks if a value is present, or omit both if the field is null.

    =Fields!QName.Value
    + IIF(ISNOTHING(Fields!QHostname.Value),"", vbCrLf + Fields!QHostname.Value)
    + IIF(ISNOTHING(Fields!Qtag.Value),"", vbCrLf + Fields!Qtag.Value)
    + IIF(ISNOTHING(Fields!QSerial.Value),"", vbCrLf + Fields!QSerial.Value)
    + IIF(ISNOTHING(Fields!QCategory.Value),"", vbCrLf + Fields!QCategory.Value)
    + IIF(ISNOTHING(Fields!QType.Value),"", vbCrLf + Fields!QType.Value)
    + IIF(ISNOTHING(Fields!QItem.Value),"", vbCrLf + Fields!QItem.Value)
    + IIF(ISNOTHING(Fields!QManu.Value),"", vbCrLf + Fields!QManu.Value)
    + IIF(ISNOTHING(Fields!QModel.Value),"", vbCrLf + Fields!QModel.Value)
    + IIF(ISNOTHING(Fields!QVersion.Value),"", vbCrLf + Fields!QVersion.Value)