Topic Options
#24661 - 09/08/09 03:31 PM Leading zeros
pfriden Offline
Junior Member

Registered: 09/08/09
Posts: 3
Loc: Norway
I have an expression which is supposed to put Leading zeros to Norwegian zip codes. The zip code should always be 4 digits. This works with PSM version 5 but I can't get it to work with version 6. The expression is: IF(LEN( [Postnr])= 2,"00" &

Top
#24662 - 09/08/09 03:34 PM Re: Leading zeros
Raphael Lalonde Lefebvre Offline
OL Expert

Registered: 10/14/05
Posts: 4956
Loc: Objectif Lune Montreal
pfriden,

Did you try changing your variable's type to Text? Go to the variables list(Window->Variables if you don't see it), select the variable that contains the zip code, and in it's properties(Window->Properties), change it's type to Text.

Let us know if that works!

Regards,
Rapha

Top
#24663 - 09/08/09 04:59 PM Re: Leading zeros
pfriden Offline
Junior Member

Registered: 09/08/09
Posts: 3
Loc: Norway
Thank you! That made the difference. I've tried to do the formatting in Excel but that didn't work.
Regards
/Per

Top
#24664 - 09/09/09 07:32 AM Re: Leading zeros
Anonymous
Unregistered


You can also use RIGHT("000" & [postnr],4) - also works if there's 1 digit in the database.

Top
#24665 - 09/09/09 02:43 PM Re: Leading zeros
pfriden Offline
Junior Member

Registered: 09/08/09
Posts: 3
Loc: Norway
Thanks! I had never used the Function "Right" in that way. That is much easier. The database included a one digit zip code so I had already extended my expression. This one I can remeber.
/Per

Top
#24666 - 09/15/09 11:55 AM Re: Leading zeros
sellis Offline
OL Newbie

Registered: 07/11/07
Posts: 19
I find using "COUNTER([Variable],[Variable],0,6,True)" works well. You can adjust the amount of leading zeros without the need to know the length of the field/variable.

Top