Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to split data into multiple columns based on condition?

Hi All,

How to split data into multiple columns based on condition?

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.

4 Replies
shraddha_g
Partner - Master III
Partner - Master III

Try

subfield(A,':',1) as B

Subfield(A,':',2) as C

Anonymous
Not applicable
Author

Hi Shraddha,

Thanks for u r replay,but the out put is not  showing some records like with '-'

.   

ABC
Apple - Banana -MilkApple - Banana -Milk
Apple - Banana -Milk - CoffeeApple - Banana -Milk - Coffee
Apple : BananaApple Banana
Orange : BananaOrange Banana
Orange : Banana - TeaOrange Banana - Tea

Thanks,

Krishna

shraddha_g
Partner - Master III
Partner - Master III

Try

if(index(A,':')>0,subfield(A,':',1) ,subfield(A,'-',1) ) as B,

if(index(A,':')>0,subfield(A,':',2) ,subfield(A,'-',2) ) as C,

Anonymous
Not applicable
Author

In your Example you're using different separators, is that so?