Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load if...

Hi guys i have a quick question, is it possible to load a specific file dependent on variable? E.G.

*******************

If var1=1

load

*

from file1

*******************

if var1=2

load

*

from file2

***********************

Thanks

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi,

Yes, use the following in your script:

IF $(var1) = 1 THEN

Table:

LOAD *

FROM File1;

ELSEIF $(var1) = 2 THEN

Table:
LOAD *

FROM File2;

END IF

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

View solution in original post

3 Replies
Miguel_Angel_Baeyens

Hi,

Yes, use the following in your script:

IF $(var1) = 1 THEN

Table:

LOAD *

FROM File1;

ELSEIF $(var1) = 2 THEN

Table:
LOAD *

FROM File2;

END IF

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

Not applicable
Author

Hi, thanks very much Miguel, this is working if i use numbers for the variables, but if i use text it does not seem to work, what i am doing wrong?

if $(var1)=1 works, but if $var1)='qwerty' or even without the single quotes i cant seem to get it to work.

Many Thanks

Miguel_Angel_Baeyens

Hi,

Note that as it happens with fields, variables in QlikView are case sensitive for both names and values. Try instead

IF var1 = 'abc' THEN

Without expanding the variable with $().

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica