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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to split column in to two columns

Hi,

I have Address column like below

32 Beach Drive, Scratby, Great mouth, folk, UK, UY29 3NP

How can I get 32 Beach Drive, Scratby, Great mouth, folk, UK in one column and UY29 3NP in another column.

can anyone help me please.

Thanks.

1 Solution

Accepted Solutions
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi Amelia,

you could try these two expressions:

Left(Field, index(Field, ',',substringcount( Field, ',')) - 1)

mid(Field, index(Field, ',',substringcount( Field, ',')) + 1)

Marcus

View solution in original post

37 Replies
jagannalla
Partner - Specialist III
Partner - Specialist III

Hi,

Load SubField(Address,',') as Address from table;

Sorry I think you need to us if condition.

Load

If (Address ='UY29' or Address='3NP',Address) as Col1,

If (Address <> 'UY29' and Address <> '3NP',Address) as Col2

from table;

Cheers!!

Jagan

marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi Amelia,

you could try these two expressions:

Left(Field, index(Field, ',',substringcount( Field, ',')) - 1)

mid(Field, index(Field, ',',substringcount( Field, ',')) + 1)

Marcus

Not applicable
Author

Hi Amelia, Nagan

Subfield is OK but you have to specify the position of the comma you want to split.

If no position, default is 0 and will split as 32 Beach Drive only


So you need to split

SubField(Address,',', 5) to get the last field


to get the whole other part, you may trick with

left(your-string, len(your_string - len(SubField(Address,',', 5)-2))


len(SubField(Address,',', 5)-2))  this will gives you the len to remove from the original string


best regards

chris

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

For the first string

=Left('32 Beach Drive, Scratby, Great mouth, folk, UK, UY29 3NP', index('32 Beach Drive, Scratby, Great mouth, folk, UK, UY29 3NP', ', ', 5) -1)

For the second string

SubField('32 Beach Drive, Scratby, Great mouth, folk, UK, UY29 3NP', ', ', 6)

Regards,

Jagan.

MayilVahanan

Hi

Try like this

SubField('32 Beach Drive, Scratby, Great mouth, folk, UK, UY29 3NP', ',',-1)

SubField(Address,',', -1)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
alexandros17
Partner - Champion III
Partner - Champion III

This is a general solution, hope it helps

LOAD * INLINE

NUM,Address

1,"32 Beach Drive, Scratby, Great mouth, folk, UK, UY29 3NP" 

2,"42 Beach Drive, Scratby, Great mouth, folk, aaa, UK, vvvv"

3,"52 Beach Drive, Scratby, Great mouth, folk, bbb, ccc, UK, kkkk"

4,"62 Beach Drive, Scratby, Great mouth, folk, UK, zzzz"

]




EVAL:

NoConcatenate

LOAD *,

Left(Address, FindOneOf(Address, ',', SubStringCount(Address, ','))-1) as FirstPart,

Mid(Address, FindOneOf(Address, ',', SubStringCount(Address, ','))+1) as SecondPart

Resident Data;



DROP Table Data;

rustyfishbones
Master II
Master II

try

2014-01-21_1532.png

Not applicable
Author

Hi, Thanks very much.

I can able to get this.

alexandros17
Partner - Champion III
Partner - Champion III

Hi Amelia,

please copy my example, it works and is a general solution...

Let me know