Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Switch between SQL and QVDs

Hello all,

Would you please be able to help?

I have a project where I want create a switch between loading data from SQL Select or loading from QVD

ex;

(From SQL)

Table:

  LOAD

  *;

  SQL

  Select

  *

  FROM

  brs.qv_sales;

(From QVD)

Table:

  LOAD

  *

  FROM

  [$(vFileLocation)D_tSales.qvd]

  (qvd);

So what I am trying to do is, create a variable if vLocation = 0 then load data from SQL, if vLocation = 1 then load data from QVD.

Is this possible, please help.

9 Replies
Anonymous
Not applicable
Author

in frontend or script?

Not applicable
Author

In script

PrashantSangle

Hi,

You can use IF Else in script.

Regards,

Prashant

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
PrashantSangle

Hi

syntax should be like

Set vLocation=1;

if  '$(vLocation)' = '1' then 

  SQL Query; 

else    

  QVD query 

end if

Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
jyothish8807
Master II
Master II

Try like this:

LET vQVDcheck = isnull(QvdCreateTime('QVD Location'));

if $(vQVDcheck ) = -1 THEN

Load from SQL

else

ab:

Load from SQL;

concatenate

Load from QVD;

Store ab in to ab.qvd;

Br,

KC

Best Regards,
KC
PrashantSangle

Hi,

You can also use Switch Case statement.

Syntax :

Let vLocation=1;

Switch vLocation

     case 1 :

          SQL Query;

     case 2 :

           Load Query;

End Switch;

Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

Hi Prashant,

I have tried the Switch Case statement, but the queries will be a lot as I have a big dashboard, I mean with lots of scripts, and adding Switch Case to each and every query wouldn't look really appealing.

Am I correct that I will need to add the Switch Case statement in each query?

PrashantSangle

Yes..

Or you can create loop in if else clause.

Regards,

Prashant

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

You can try this by using variables. If you have 10 load statements, you need 10 variables.

The variable is initialised based on the vLocation. Some thing like below

if vlocation=1 then assign the below to vLoad1

"SQL

  Select

  *

  FROM

  brs.qv_sales;

"

if vlocation=0 then assign the below to vload1

LOAD

  *

  FROM

  [$(vFileLocation)D_tSales.qvd]

  (qvd);

then you can use the vLoad1 in the script.

hope this helps.