Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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
AreaSmiley Very Happy 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
MVP
MVP

Re: Split String in parts

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

];

3 Replies
Not applicable

Re: Split String in parts

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.

MVP
MVP

Re: Split String in parts

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

Re: Split String in parts

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

Community Browser