Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Now accepting applications for the Qlik Luminary and Partner Ambassador Programs: Apply by July 6!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

UK Postcode Formatting

Hi,

I hope someone is able to help me with my query.

I have a large amount of data I need to feed into Qlikview and i'm having issues formatting the Postcode field.  What I need is to convert a full postcode into a 5 character code.  As UK postcodes come in all different shapes and sizes this is proving to be a little bit trickier than I first envisaged.

I'll try and show examples of what i'm looking for below.

Original Postcode          5 Character Version (The format I need)

LL32 8AJ                        LL328

BB7 3ER                        BB7 3 (Includes 1 space)

L1 8EE                           L1  8 (Includes 2 spaces)

IP12 2UE                       IP122

W1W 5NU                     W1W 5 (Includes 1 space)

I hope this gives a good idea of exactly what i'm after?

Cheers,

Paul

Labels (1)
1 Solution

Accepted Solutions
MarcoWedel
MVP
MVP

Hi,

one solution could be:

QlikCommunity_Thread_186045_Pic1.JPG

tabPostcodes:

LOAD *,

    SubField(Postcode,' ',1)&Repeat(' ',4-Len(SubField(Postcode,' ',1)))&Left(SubField(Postcode,' ',2),1) as Postcode2

Inline [

Postcode

LL32 8AJ

BB7 3ER

L1 8EE

IP12 2UE

W1W 5NU

];

hope this helps

regards

Marco

View solution in original post

3 Replies
MarcoWedel
MVP
MVP

Hi,

one solution could be:

QlikCommunity_Thread_186045_Pic1.JPG

tabPostcodes:

LOAD *,

    SubField(Postcode,' ',1)&Repeat(' ',4-Len(SubField(Postcode,' ',1)))&Left(SubField(Postcode,' ',2),1) as Postcode2

Inline [

Postcode

LL32 8AJ

BB7 3ER

L1 8EE

IP12 2UE

W1W 5NU

];

hope this helps

regards

Marco

Not applicable
Author

Hi Marco,

Thank you ever so much for your assistance.  The code provided works perfectly

Cheers,

Paul

MarcoWedel
MVP
MVP

‌You're welcome.

regards

Marco