Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
Hi,
one solution could be:
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
Hi,
one solution could be:
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
Hi Marco,
Thank you ever so much for your assistance. The code provided works perfectly
Cheers,
Paul
You're welcome.
regards
Marco