Formatting the Zip code depending on size

2 posts, 0 answers
  1. SSirica
    SSirica avatar
    111 posts
    Member since:
    Jan 2007

    Posted 12 Sep 2019 Link to this post

    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?

  2. Neli
    Neli avatar
    365 posts

    Posted 17 Sep 2019 Link to this post

    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),

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

    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
Back to Top