Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
twills12
Contributor III
Contributor III

Struggling with load statement coding

I have data being populated in an excel form such as this that I'm loading into my application...

column A
Field A: This is the data for Field A.
Field B: Some other data is populated here.
Field C: Still some other data to be found here.
Field 😧 Yet other data here.
...
...
Field X: Something more here.

I would like to structure the load so that I have a resulting table such as this...

Field AField BField CField DField X
This is the data for Field A.Some other data is populated here.Still some other data to be found here.Yet other data here.Something more here.

Any suggestions appreciated!

1 Solution

Accepted Solutions
Nicole-Smith

Load script like this:

Temp:

LOAD * INLINE [

column A

Field A: This is the data for Field A.

Field B: Some other data is populated here.

Field C: Still some other data to be found here.

Field 😧 Yet other data here.

Field X: Something more here.

];


FOR i=1 TO NoOfRows('Temp')


LET Field = '[' & SUBFIELD(PEEK('column A', $(i)-1, 'Temp'), ': ', 1) & ']';

LET Value = CHR(39) & SUBFIELD(PEEK('column A', $(i)-1, 'Temp'), ': ', 2) & CHR(39);

IF $(i) = 1 THEN

      Data:

      LOAD $(Value) AS $(Field)

      AutoGenerate 1;

ELSE

      LEFT JOIN (Data)

      LOAD $(Value) AS $(Field)

      AutoGenerate 1;

ENDIF


NEXT


Will return a table that looks like this:

Field A Field B Field C Field D Field X
This is the data for Field A.Some other data is populated here.Still some other data to be found here.Yet other data here.Something more here.

View solution in original post

2 Replies
Nicole-Smith

Load script like this:

Temp:

LOAD * INLINE [

column A

Field A: This is the data for Field A.

Field B: Some other data is populated here.

Field C: Still some other data to be found here.

Field 😧 Yet other data here.

Field X: Something more here.

];


FOR i=1 TO NoOfRows('Temp')


LET Field = '[' & SUBFIELD(PEEK('column A', $(i)-1, 'Temp'), ': ', 1) & ']';

LET Value = CHR(39) & SUBFIELD(PEEK('column A', $(i)-1, 'Temp'), ': ', 2) & CHR(39);

IF $(i) = 1 THEN

      Data:

      LOAD $(Value) AS $(Field)

      AutoGenerate 1;

ELSE

      LEFT JOIN (Data)

      LOAD $(Value) AS $(Field)

      AutoGenerate 1;

ENDIF


NEXT


Will return a table that looks like this:

Field A Field B Field C Field D Field X
This is the data for Field A.Some other data is populated here.Still some other data to be found here.Yet other data here.Something more here.
twills12
Contributor III
Contributor III
Author

Thanks Nicole!!!