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: 
Wallibee
Contributor III
Contributor III

Slitting field values

I am trying to slip data but it happens to be tricky

example 

Field A

A,B(a,b,c,d,f),C

X(a,b,c,d,f),Y,Z

expected output 

Field A

A

B(a,b,c,d,f)

C

X(a,b,c,d,f)

Y

Z

can someone inject me with experience 😊

2 Solutions

Accepted Solutions
tresesco
MVP
MVP

Take this injection, however, I am not sure if another dose would be required for better immunity. 😋

Load Replace(Splitted, '@', ',') as FinalString;
Load SubField(NewField,',') as Splitted;
Load
Left(FieldA, Index(FieldA, '(')) &
Replace(TextBetween(FieldA, '(', ')'),',','@')
& Right(FieldA, Len(FieldA)-Index(FieldA, ')')+1) as NewField
;
Load * Inline [
FieldA
A,B(a,b,c,d,f),C
X(a,b,c,d,f),Y,Z] (delimiter is '|')

View solution in original post

3 Replies
Saravanan_Desingh

Try this,

tab1:
LOAD * INLINE [
F1
"A,B(a,b,c,d,f),C"
"X(a,b,c,d,f),Y,Z"
];

Left Join(tab1)
LOAD *, Mid(F1,IterNo(),1) As C1, IterNo() As N1
Resident tab1
While IterNo() <= Len(F1)
;

Left Join(tab1)
LOAD *, If(C1='(','I', If(F1=Peek(F1) And Not C1=')',Peek(K1),'N')) As K1
Resident tab1;

Left Join(tab1)
LOAD F1,C1,K1,N1, If(C1=',',If(K1='I', '~',C1),C1) As C2
Resident tab1;

Left Join(tab1)
LOAD F1, Concat(C2,'',N1) As F2
Resident tab1
Group By F1;

tab2:
LOAD Replace(SubField(F2,','),'~',',') As FieldA
Resident tab1;

Drop Table tab1;
tresesco
MVP
MVP

Take this injection, however, I am not sure if another dose would be required for better immunity. 😋

Load Replace(Splitted, '@', ',') as FinalString;
Load SubField(NewField,',') as Splitted;
Load
Left(FieldA, Index(FieldA, '(')) &
Replace(TextBetween(FieldA, '(', ')'),',','@')
& Right(FieldA, Len(FieldA)-Index(FieldA, ')')+1) as NewField
;
Load * Inline [
FieldA
A,B(a,b,c,d,f),C
X(a,b,c,d,f),Y,Z] (delimiter is '|')