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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to split column value to multiple column values in straight table

Hi,

I have one address field

for eg: 12 Oak Tree Drive,Cave Hollod, Hadgoed ,Mid Glamorgan , , CF22 8TN

I need to split the above address as

Address1 = 12 Oak Tree Drive

Address2 = Cave Hollod

Address3 = Hadgoed

Town = Mid Glamorgan

County = ' '

PostCode = CF22 8TN

Could anyone help me please how to write the expressions in Straight table.

Thanks.

9 Replies
Not applicable
Author

Use subfield:

subfield(s, 'delimiter' [ , index ] )

In its three-parameter version, this script function returns a given substring from a larger string s with delimiter 'delimiter'. index is an optional integer denoting which of the substrings should be returned. If index is omitted when subfield is used in a field expression in a load statement, the subfield function will cause the load statement to automatically generate one full record of input data for each substring that can be found in s.

In its two-parameter version, the subfield function generates one record for each substring that can be taken from a larger string s with the delimiter 'delimiter'. If several subfield functions are used in the same load statement, the Cartesian product of all combinations will be generated.

Examples:

(For three parameters)

subfield(S, ';' ,2) returns 'cde' if S is 'abc;cde;efg'

subfield(S, ';' ,1) returns NULL if S is an empty string

subfield(S, ';' ,1) returns an empty string if S is ';'

The LOAD statement will look like this:

LOAD

               subfield(@1, ',', 1) as Address1

               subfield(@1, ',', 2) as Address2

               subfield(@1, ',', 3) as Address3

               subfield(@1, ',', 4) as Town

               subfield(@1, ',', 5) as County

               subfield(@1, ',', 6) as Postcode

FROM

Be aware that the comma can only be used as a delimiter.

Not applicable
Author

Thanks for your reply could you let me know in the subfield where can I use the columnname . The column is Home_address

Not applicable
Author

I used @1 for the columnname.

So replacing the first parameter in the subfield-statement by Home_address is what you're looking for.

MayilVahanan

Hi

LOAD

               subfield(Home_address, ',', 1) as Address1

               subfield(Home_address, ',', 2) as Address2

               subfield(Home_address, ',', 3) as Address3

               subfield(Home_address, ',', 4) as Town

               subfield(Home_address, ',', 5) as County

               subfield(Home_address, ',', 6) as Postcode

FROM TableName

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

Hi,

Try like this

LOAD

               subfield(Home_address, ',', 1) as Address1

               subfield(Home_address, ',', 2) as Address2

               subfield(Home_address, ',', 3) as Address3

               subfield(Home_address, ',', 4) as Town

               subfield(Home_address, ',', 5) as County

               subfield(Home_address, ',', 6) as Postcode

FROM TableName;

Regards,

Jagan.

Not applicable
Author

Thanks for your help but in the blank values it is showing Town,County and Postcode. Could you let me know how to adjust this please.


Not applicable
Author

Thanks for your help but in the blank values it is showing again the same problem. could you please help

Not applicable
Author

Thanks and sorry it's getting the same way as earlier. could you please help.

MayilVahanan

HI

Can you please attach sample

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