Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $300 before February 6: REGISTER NOW!
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

1 Solution

Accepted Solutions
MarcoWedel

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

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

‌You're welcome.

regards

Marco