Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Daniel1990,
Try this
let vDB = 1; //vDB = 2;
Table:
Load
if ($(vDB) = 1, 'Field 1', 'Field 2')as "New Field Name";
SQL Select *
From sourcetable;
Regards,
Sokkorn Cheav
If you want to load a filed NAMED "Field 1", and not loading the value "Field 1", then:
let vDB = 1; //vDB = 2;
Table:
Load
if ($(vDB) = 1, [Field 1], [Field 2]) as [New Field Name];
SQL Select *
From sourcetable;
Hi,
thanks for the fast answers.
Unfortunately it does not solve the problem.
Maybe i have to add a few supplementations:
With the variable vDB I will load data from two different databases. If it is set to 1 Load from database 1, if it is set to 2 load from database 2.
Now the problem is, that in the table in database 1 the field, i want to load, is named "Field 1" and in database 2 it is named "Field 2". There is no "Field 1" in database 2 and no "Field 2" in Database 1.
If I try this:
let vDB = 2; //load from database 2 where "Field 1" not exists
if ($(vDB) = 1, [Field 1], [Field 2]) as [New Field Name]; //now i want to load "Field 2" from the Else-statement
it is the same error. Field not exists. "Field 1"
I would think it is impossible in QlikView.
Thanks a lot for your help.
regards,
Daniel1990
If the fields are in different databases, then you have to bring them first toghether inside QlikView. After that you can use your IF().
// bring the first field
ODBC Connect to Database1;
Temp_Table:
SELECT [key], [Field 1]
FROM Table1;
// bring the second field
ODBC Connect to Database2;
JOIN (Temp_Table)
SELECT [key], [Field 2]
FROM Table2;
let vDB = 2; //load from database 2 where "Field 1" not exists
LOAD [key],
if ($(vDB) = 1, [Field 1], [Field 2]) as [New Field Name]
RESIDENT Temp_Table;