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: 
ciaran_mcgowan
Partner - Creator III
Partner - Creator III

Separate Field into Multiple (varying amount of Subfields)

Hi all,

I have two files; Drivers & Delivery.

Drivers is small and contains personal information about driver details (Name, Age, etc.). Delivery contains information about individual deliveries but they are not associates to the Driver table because:

DateFromToSent
01/12/2015DepotShop APaul & John
02/12/2015DepotShop BPaul, John, Ringo & George
03/12/2015DepotShop CJohn, George & Ringo
04/12/2015DepotShop DRingo

I need to separate out the Sent field so it will join to the Name field in the Driver table. I've created the following to determine how many Drivers were sent for each delivery:

if(SubStringCount(Sent,',')=0 AND SubStringCount(Sent,'&')=0, 1,

     SubStringCount(Sent,',')+2)

          AS DriverCount


Does anyone know the most efficient way to loop through the table in the script and separate each Driver into a new row?

1 Solution

Accepted Solutions
sunny_talwar

May be this in the script:

SubField(Replace(Sent, '&', ','), ', ') as Sent

Sample


Table:

LOAD Date,

     From,

     To,

     SubField(Replace(Sent, '&', ','), ', ') as Sent

FROM

[https://community.qlik.com/thread/197040]

(html, codepage is 1252, embedded labels, table is @1);

Capture.PNG

View solution in original post

4 Replies
sunny_talwar

May be this in the script:

SubField(Replace(Sent, '&', ','), ', ') as Sent

Sample


Table:

LOAD Date,

     From,

     To,

     SubField(Replace(Sent, '&', ','), ', ') as Sent

FROM

[https://community.qlik.com/thread/197040]

(html, codepage is 1252, embedded labels, table is @1);

Capture.PNG

ciaran_mcgowan
Partner - Creator III
Partner - Creator III
Author

Thanks for the speedy response.

I came across this issue a couple of years ago and remember having to loop through the table until the maxium DriverCount had been reached, but this actually worked a treat.

So much simpler, I didn't realise that Subfield() worked like that if a subfield number wasn't specified!

sunny_talwar

In the script it does. But I don't think it would work like this on the front end.

ciaran_mcgowan
Partner - Creator III
Partner - Creator III
Author

Good to know. Thanks