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: 
Not applicable

Dynamic LOAD Statement

Dear Community,

I am trying to build a solution that allows external configuration of Loads statements that are then "calculated" in QlikView script. As you may know, variables can be used for field values or field names. Examples as the following do work fine:

LOAD '$(var)' AS field

SQL SELECT ...

However I wondered if there is a way to fully replace the LOAD Statement by a single Variable as in the following example:

LOAD $(var);

where var = Field1, Field2, Field3 AS RenamedField;

Unfortunately I either get the original SQL field names or an error depending on the syntax I use. Does anyone know how to make the LOAD part fully variable?

Thank you

1 Solution

Accepted Solutions
Not applicable
Author

Not exactly what I am looking for. The source is dynamic indeed, but I wanted the fields to be dynamic as well.

I found the solution last night:

LET var = 'Field1, Field2, Field2 AS RenamedField';

LOAD $(var);

SQL SELECT...

is not beeing recognized as a valid statement. But using a dummy field before the variable will do:

LOAD 1 AS DummyField,

          $(var);

SQL SELECT...

DROP FIELD DummyField

View solution in original post

4 Replies
sujeetsingh
Master III
Master III

See this may help you.

Not applicable
Author

Not exactly what I am looking for. The source is dynamic indeed, but I wanted the fields to be dynamic as well.

I found the solution last night:

LET var = 'Field1, Field2, Field2 AS RenamedField';

LOAD $(var);

SQL SELECT...

is not beeing recognized as a valid statement. But using a dummy field before the variable will do:

LOAD 1 AS DummyField,

          $(var);

SQL SELECT...

DROP FIELD DummyField

hic
Former Employee
Former Employee

I think your first attempt will run just fine. It is just the color coding in the script that doesn't understand.

HIC

Not applicable
Author

Hi Henric,

not the first attempt didn't execute as it as supposed. In fact the example was i bit more complex and in the end the LOAD part was ignored and I received the pure SQL result - but also not error message.

best regards