Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

split a column into new columns by character in qliksense

Hi all,

I have a csv file with a specific field like this:

TYPE

AT IT BA

IT BA

AT BA LB

RT LB


I want to create something like:

TYPE                  OPTION1              OPTION2               OPTION3

AT                    IT                   IT                    BA

IT                    BA

AT                    BA                   LB

RT                    LB

How i can do it?

Thanks!

1 Solution

Accepted Solutions
MVP
MVP

Re: split a column into new columns by character in qliksense

with subfield function

X:

LOAD

subfield(TYPE, ' ', 1) as TYPE,

subfield(TYPE, ' ', 2) as OPTION1,

subfield(TYPE, ' ', 3) as OPTION2,

subfield(TYPE, ' ', 4) as OPTION3

FROM a.csv

(txt, codepage is 1252, embedded labels, delimiter is ';', msq);

subfield also works in chart

5 Replies

Re: split a column into new columns by character in qliksense

I think when you load CSV you are able to specify the delimiter. Have you tried to specify <space> as your delimiter?

MVP
MVP

Re: split a column into new columns by character in qliksense

try

LOAD @1 as TYPE, @2 as OPTION1, @3 as OPTION2, @4 as OPTION3

FROM yourfile.csv

(txt, codepage is 1252, no labels, delimiter is spaces, msq, header is 1 lines);

Not applicable

Re: split a column into new columns by character in qliksense

Thanks! Some way to do without using the load statement?

Regards.

Not applicable

Re: split a column into new columns by character in qliksense

If not, my file has a lot of columns, how i can adjust the load script to only split the desired column?

Regards.

MVP
MVP

Re: split a column into new columns by character in qliksense

with subfield function

X:

LOAD

subfield(TYPE, ' ', 1) as TYPE,

subfield(TYPE, ' ', 2) as OPTION1,

subfield(TYPE, ' ', 3) as OPTION2,

subfield(TYPE, ' ', 4) as OPTION3

FROM a.csv

(txt, codepage is 1252, embedded labels, delimiter is ';', msq);

subfield also works in chart

Community Browser