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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out 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

Labels (1)
1 Solution

Accepted Solutions
swuehl
Champion III
Champion III

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
Champion III
Champion III

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