Natan
Natan

Reputation: 139

SQL SSRS add if condition into ssrs expression

I am creating a simple report in SSRS One of the fields is an address, which has this expression value

=First(Fields!BILL_CITY.Value) & ", " & Fields!BILL_PROV.Value & " " & Fields!BILL_ZIP.Value

What I want to do, is within that expression within SSRS, I want to add a condition.

If the Fields!BILL_ZIP.Value is only 5 digits, do nothing. If the value is more than 5 digits, add a dash after the fifth digit.

So if customer sends the shorthand version of the zipcode it will appear as 45040 but if he sends the long version, it will be 45040-8999

Does anybody know how to do this? Creating the condition probably wouldn't be too hard, but how do I put it within the SSRS expression format?

Upvotes: 0

Views: 1264

Answers (1)

B. Seberle
B. Seberle

Reputation: 395

Try:

= IIF(LENGTH(Fields!BILL_ZIP.Value) = 5, Fields!BILL_ZIP.Value & "-", Fields!BILL_ZIP.Value)

Upvotes: 1

Related Questions