Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to use subfield function for different separators

Hi All,

How to use subfield function for different separators ?

Raw data:

A

Apple : Banana

Orange : Banana

Apple - Banana -Milk

Apple - Banana -Milk - Coffee

Orange : Banana - Tea

Output:

A

B

C

Apple : Banana

Apple

Banana

Orange : Banana

Orange

Banana

Apple - Banana -Milk

Apple

Banana -Milk

Apple - Banana -Milk - Coffee

Apple

Banana -Milk -Coffee

Orange : Banana - Tea

Orange

Banana - Tea

Thanks,

Krishna.

1 Solution

Accepted Solutions
sunny_talwar

Try this

Table:

LOAD A,

SubField(A, ' ', 1) as B,

Mid(A, Len(SubField(A, ' ', 1))+4) as C;

LOAD * INLINE [

    A

    Apple : Banana

    Orange : Banana

    Apple - Banana -Milk

    Apple - Banana -Milk - Coffee

    Orange : Banana - Tea

];

View solution in original post

3 Replies
swuehl
MVP
MVP

You can first REPLACE() all different separators to a common one, then use SUBFIELD().

sunny_talwar

Try this

Table:

LOAD A,

SubField(A, ' ', 1) as B,

Mid(A, Len(SubField(A, ' ', 1))+4) as C;

LOAD * INLINE [

    A

    Apple : Banana

    Orange : Banana

    Apple - Banana -Milk

    Apple - Banana -Milk - Coffee

    Orange : Banana - Tea

];

Anonymous
Not applicable
Author

Thanks sunny