Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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

Tags (1)
1 Solution

Accepted Solutions

Re: UK Postcode Formatting

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

3 Replies

Re: UK Postcode Formatting

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

Re: UK Postcode Formatting

Hi Marco,

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

Cheers,

Paul

Re: UK Postcode Formatting

‌You're welcome.

regards

Marco

Community Browser