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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Split String in parts

Who can help me.

I have a string, named Service.
I want to devide the string into three separate parts, named: Area, Function and Systeem.


The structure from Service is as follows:
Layout Service:Number,Space,Area,-,Number,Space,Function,-,Number,Space,Systeem

For example:5 D PIER-02 LATERALS-50240 LATERALS NOORD
Area:D PIER
Function:LATERALS
Systeem:LATERALS NOORD

Next example:3 TERMINAL 2-33 ALT LOSINSTALLATIE (MUM)-53301 ALT LOSINSTALLATIE 21
Area:TERMINAL 2
Function:ALT LOSINSTALLATIE (MUM)
Systeem:ALT LOSINSTALLATIE 21

I want to use the script in the loadscript.

Can someone help me with this.

Thanks in advance,

Frans

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe like this:

LOAD *,

mid(subfield(TXT,'-',1),index(TXT,' ')) as Area,

mid(subfield(TXT,'-',2),index(TXT,' ',2)) as Function,

mid(subfield(TXT,'-',3),index(subfield(TXT,'-',3),' '))  as System

INLINE [

TXT

5 D PIER-02 LATERALS-50240 LATERALS NOORD

3 TERMINAL 2-33 ALT LOSINSTALLATIE (MUM)-53301 ALT LOSINSTALLATIE 21

];

View solution in original post

3 Replies
Not applicable
Author

Try using FindOneOf() this will let you find the position of the - delimeter you have and then it is just using a mix of left, mid, right and len to split it down for you.

swuehl
MVP
MVP

Maybe like this:

LOAD *,

mid(subfield(TXT,'-',1),index(TXT,' ')) as Area,

mid(subfield(TXT,'-',2),index(TXT,' ',2)) as Function,

mid(subfield(TXT,'-',3),index(subfield(TXT,'-',3),' '))  as System

INLINE [

TXT

5 D PIER-02 LATERALS-50240 LATERALS NOORD

3 TERMINAL 2-33 ALT LOSINSTALLATIE (MUM)-53301 ALT LOSINSTALLATIE 21

];

Not applicable
Author

Thanks it works, i convert the second code from

mid(subfield(TXT,'-',2),index(TXT,' ',2)) as Function to

mid(subfield(TXT,'-',2),index(subfield(TXT,'-',2),' '))  as Function.

After that Function works also correct.

Thank you.

Frans