Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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

Re: Dynamic LOAD Statement

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

4 Replies
sujeetsingh
Honored Contributor III

Re: Dynamic LOAD Statement

See this may help you.

Not applicable

Re: Dynamic LOAD Statement

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

Employee
Employee

Re: Dynamic LOAD Statement

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

Re: Dynamic LOAD Statement

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

Community Browser