This is a migrated thread and some comments may be shown as answers.

Formatting the Zip code depending on size

1 Answer 120 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
SSirica
Top achievements
Rank 3
Iron
Iron
Iron
SSirica asked on 12 Sep 2019, 07:13 PM

I have a report (trdp) with a zip code field.  some of the data has the zip code saved as 5 digits some have 9 (ie. 12345-4578).  If the data length is 5 I want the report to display 01245 if it's length is > 5 I want to display 01245-7845. 

How would one acomplish this without using a user defined function?

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 17 Sep 2019, 11:35 AM

Hello SSirica,

 

You can use the Conditional Function IIf and the Text Function, Len, to check for the length of the zip. Then you need Substr to get the substrings from the zip code. The expression may look as follows:

= IIF(Len(Fields.Zip) > 5 ,
Substr(Fields.Zip,0,5) + "-" + Substr(Fields.Zip,5,4),
Fields.Zip)

You can also check the attached report which demonstrates the approach.

Regards,
Neli
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
SSirica
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Neli
Telerik team
Share this question
or