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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Gabri11
Contributor
Contributor

Split string and find index

hi, I have two fields (field1 and field2). field1 is of the type "800; 805; 116; 809; 804; 830; 346; 345; 890; 881; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0" while field2 is of the type "1; 0; 215; 0; 0; 1; 2; 66; 5; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0". I would need to extract from field2 the value corresponding to the index searched in field1 (eg I look for "800" in field1 and extract "1" from field2, for example I look for "116" in field1 and extract "215" from field2). This I would need to do it within tmap.

I hope I have not made too much confusion ..... 🙂
thanks a lot

Labels (2)
1 Solution

Accepted Solutions
akumar2301
Specialist II
Specialist II

in Tmap buiding expression, use below expression

field2.split(";")[java.util.Arrays.asList(field1.split(";")).indexOf("stringtosearch")]

e.g.
String f1 = "800;801;802;803";
String f2 = "X;Y;Z;G";
f2.split(";")[java.util.Arrays.asList(f1.split(";")).indexOf("801")]
this will return Y

View solution in original post

3 Replies
vapukov
Master II
Master II

Hi

 

you can do this thru Java code, and if you want to do this with build components:

  • use tNormalize for split row into many rows
  • add row number to the flow - sequence
  • join in tMap by row number

 

regards, Vlad

akumar2301
Specialist II
Specialist II

in Tmap buiding expression, use below expression

field2.split(";")[java.util.Arrays.asList(field1.split(";")).indexOf("stringtosearch")]

e.g.
String f1 = "800;801;802;803";
String f2 = "X;Y;Z;G";
f2.split(";")[java.util.Arrays.asList(f1.split(";")).indexOf("801")]
this will return Y
Gabri11
Contributor
Contributor
Author

thank you 🙂