Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Ignore text after a special character

Hi everyone,

I have a string which is a persons address, often this ends with a postcode ....AB11AB, or something the postcode will be AB121AB. I used an expression found on here to extract the postcode if it is the last part of the string:

REPLACE(

     TRIM

     (right(PatientFullAddress,7)  &

      subfield

       (subfield

        (PatientFullAddress,right

         (PatientFullAddress,7)

        ,-1)

       ,' ','')

      )

     ,' ','') as PatientPostcode2,

  left(subfield(Postcode,' ',1),len(subfield(Postcode,' ',1)))

But I have found the address string sometimes has AB11AB : house number (Insert a number here for this example).

How can I use the above but exclude all of the text after the ':', or is there a way to improve what I have already?

Many thanks

Labels (1)
2 Replies
matt_crowther
Specialist
Specialist

To isolate everything prior to the ':' I'd look to use something in the load script like:

left(MyValues,index(MyValues,':')-2) as MyVlaues

That assumes you have a space between the end of the PostCode and the ':'.

Obviously replace 'MyValues' with your text string.

Hope that helps,

Matt - Visual Analytics Ltd

Qlikview Design Blog: http://QVDesign.wordpress.com

@QlikviewBI

Not applicable
Author

Hi Matt, thanks for teh reply. I could only get this to work on those records where the address contains ':'. I would ike it to include the other entries as well e.g.

anystreet AB11YZ: 9876

anyplace AB114NB

the above would turn out: -

AB11YZ

AB114NB

Many thanks