Jump to content

Calculation to format Canadian Postal Code


This topic is 6447 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I need to format a postal code. I have about 400 of them in my database and this code includes both letters & numbers (example: K0J1L0 is what was imported. I need it to appear

K0J 1L0). It seems easy enough to add this space between the first 3 and last 3 letters/numbers. I used the following:

Let (

imput = Filter (Postal Code; "0123456789")

; Left (imput; 3) & " " & Right (imput; 3)

)

I formated the calculation to be text.

Yet it returned values that were only numbers! All of the letters became numbers!

Can you help?

Link to comment
Share on other sites

The filter return the expect results I believe.

It Filtered out everything except the "0123456789" as it reads.

In the USA, this would probably what you wanted, but I'm not familiar with the Canada's Zips patterns, so maybe you can provide a few examples of what you have now, and what you want as the results.

Lee

Edited by Guest
Link to comment
Share on other sites

You probably still need the filter to remove any non-alphanumeric characters that the user may enter, because the user may or may not enter a space between the 3rd and 4th character.

Also note, the letters D, F, I, O, Q and U are not used. So, you could set up your filter function like this:

Filter("0123456789ABCEGHJKLMNPRSTVWXYZ"

Let (

input = Filter (Postal Code; "0123456789ABCEGHJKLMNPRSTVWXYZ"); 

case(Length(input)<>6;"**INVALID**";Left (input; 3) & " " & Right (input; 3))

)

Link to comment
Share on other sites

This topic is 6447 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.