GPH
GPH

Reputation: 1897

SSRS expression - remove line breaks when field contains no data

I have an SSRS report that is a calendar, and it shows each persons different activity for each day. I currently do this via .vbcrlf to create the line break.

What I would like to do is only return a line break when there is data in the specific value.

My current expression is:

=Fields!DayOfMonth.Value 
        & Constants.vbcrlf 
        & Constants.vbcrlf 
        & Fields!Shift.Value 
        & Constants.vbcrlf 
        & Fields!OT.Value 
        & Constants.vbcrlf 
        & Fields!Holiday.Value 
        & Constants.vbcrlf 
        & Fields!AbsenceType.Value 
        & Constants.vbcrlf 
        & Fields!ClockIn.Value

So if there is no Holiday I would like to remove that line and the break meaning Absence and In/Out would move up the text box. I've tried using isNothing but cant get the syntax right.

enter image description here

Upvotes: 1

Views: 2239

Answers (2)

Jaggan_j
Jaggan_j

Reputation: 518

The syntax which worked for me in VS 2017 with SQL Server Data Tools:

=IIf(Fields!Holiday.Value Is "", "", Fields!Holiday.Value + Environment.NewLine)
+ IIf(Fields!AbsenceType.Value Is "", "", Fields!AbsenceType.Value + Environment.NewLine)

Code is pretty much self explanatory - if there is no value for Holiday, result is empty string or else if it has value, show value and line break. For latest syntax of any function, just refer to the examples given in the Expression window.

Upvotes: 0

BishNaboB
BishNaboB

Reputation: 1070

It sees the data as NULL values, which can alter the way it treats text.

You can use iif(isnothing(Field!Thing.Value), "", Constants.vbcrlf & Field!Thing.Value) around each one to replace null values with blanks.

There may be a more elegant solution available.

Upvotes: 2

Related Questions