Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

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...

Tags (1)
1 Solution

Accepted Solutions
MVP
MVP

Re: Trim to a Space

Hi,

Probably the easiest way to get it is

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

SubField(Postcode, ' ', 2) AS SecondPart

Hope that helps.

Miguel

4 Replies
MVP
MVP

Re: Trim to a Space

Maybe

LOAD

...

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

...

MVP
MVP

Re: Trim to a Space

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

Re: Trim to a Space

try this

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

Not applicable

Re: Trim to a Space

Perfect guys, thanks very much for your help!

Community Browser