Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Trim to a Space

I am looking to trim a field storing postcodes, the issue im having is that i dont want to specify the trim to a set number of characters as some first parts of a post code can be 2,3 or 4 characters long.

Is it possilbe to trim until it reaches a space, so for example

B1 2AA = B1

B12 3AA = B12

BE12 4BB = BE12

Any help would be greatly apreciated...

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi,

Probably the easiest way to get it is

SubField(Postcode, ' ', 1) AS FirstPart,

SubField(Postcode, ' ', 2) AS SecondPart

Hope that helps.

Miguel

View solution in original post

4 Replies
swuehl
MVP
MVP

Maybe

LOAD

...

subfield(POSTCODEFIELD, ' ',1) as TrimmedPostcodes,

...

Miguel_Angel_Baeyens

Hi,

Probably the easiest way to get it is

SubField(Postcode, ' ', 1) AS FirstPart,

SubField(Postcode, ' ', 2) AS SecondPart

Hope that helps.

Miguel

Not applicable
Author

try this

trim(left(str,index(str,' ')))

Not applicable
Author

Perfect guys, thanks very much for your help!