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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
leey8211
Partner - Contributor II
Partner - Contributor II

Split one field into two columns with unorganized strings and conditional character

Hello everyone, I have a column with unorganized strings like this, for example: 

      apple; NCST-00345; QTT; 83457; w456-IOKY-34569865

      banana; NEL-00985; QWZ; 345876; w-9845-mbjkh-984039842

      avocado; 345; SGY-983457; 2344; wPOierty

      ........ 

The goal is to split this column into two columns. One column contains all the strings before "w", the other column would be include everything with "w" and after "w", like this: 

original  Column one column two
apple; NCST-00345; QTT; 83457; w456-IOKY-34569865 apple; NCST-00345; QTT; 83457; w456-IOKY-34569865
banana; NEL-00985; QWZ; 345876; w-9845-mbjkh-984039842 banana; NEL-00985; QWZ; 345876; w-9845-mbjkh-984039842
avocado; 345; SGY-983457; 2344; wPOierty avocado; 345; SGY-983457; 2344; wPOierty
................ ............ .........

 

So, how can I write set expressions or script code to achieve this goal? Or, what functions should I use? I tried SubField function but it's not working well. Any advice or hint would be greatly appreciated, many thanks! 

Labels (1)
1 Solution

Accepted Solutions
PrashantSangle

Hi,

use mid() & index() to achieve the requirement

try below

Load Test, Mid(Test,1,Index(Test,'w')-1) as column1, Mid(Test,Index(Test,'w')) as column2 Inline [
Test
"apple; NCST-00345; QTT; 83457; w456-IOKY-34569865"
];

 

Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

4 Replies
PrashantSangle

Hi,

use mid() & index() to achieve the requirement

try below

Load Test, Mid(Test,1,Index(Test,'w')-1) as column1, Mid(Test,Index(Test,'w')) as column2 Inline [
Test
"apple; NCST-00345; QTT; 83457; w456-IOKY-34569865"
];

 

Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
vinieme12
Champion III
Champion III

if its always the last ';' delimited string you can also use subfield

 

load original
,subfield(original,subfield(original,';',-1),1) as firstCol
,subfield(original,';',-1) as secondCol
inline
[
original
apple; NCST-00345; QTT; 83457; w456-IOKY-34569865
banana; NEL-00985; QWZ; 345876; w-9845-mbjkh-984039842
avocado; 345; SGY-983457; 2344; wPOierty
];

 

vinieme12_0-1704438168658.png

 

 

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
leey8211
Partner - Contributor II
Partner - Contributor II
Author

Thank you Prashant, your solution works!

leey8211
Partner - Contributor II
Partner - Contributor II
Author

Thank you Vineeth, it helps!