Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Suppose I have more than 300 data table. for that i want to generate QVD's for each data table at one time.
how to do that in qlik?
@Vikash2024 you can use :
SET QVDPath = 'C:\QVDs\'; // output QVD
FOR EACH TableName IN 'Table1', 'Table2', 'Table3', 'Table4', ... // Your tables
$(TableName):
LOAD *
FROM [DataSource]
WHERE TableName = '$(TableName)';
// create QVD
STORE $(TableName) INTO [$(QVDPath)$(TableName).qvd] (qvd);
// Drop de la table
DROP TABLE $(TableName);
NEXT;
@Vikash2024 I hope you have list of table names stored somewhere so that you can loop over each table.
// list of table names
TableList:
Load TableName
FROM table;
for Each vTableName in FieldValueList('TableName')
[$(vTableName)]:
SQL SELECT *
FROM [database].[$(vTableName)];
Store [$(vTableName)] into lib://FolderConnection/QVD/$(vTableName).qvd(qvd);
Drop Table [$(vTableName)];
Next vTableName
@Vikash2024 replace TableList load as database table
// Connect to database
LIB CONNECT TO 'sql_source';
// list of table names
TableList:
SQL SELECT TableName
FROM database.table_name;
for Each vTableName in FieldValueList('TableName')
[$(vTableName)]:
SQL SELECT *
FROM [database].[$(vTableName)];
Store [$(vTableName)] into lib://FolderConnection/QVD/$(vTableName).qvd(qvd);
Drop Table [$(vTableName)];
Next vTableName
@Vikash2024 you can use :
SET QVDPath = 'C:\QVDs\'; // output QVD
FOR EACH TableName IN 'Table1', 'Table2', 'Table3', 'Table4', ... // Your tables
$(TableName):
LOAD *
FROM [DataSource]
WHERE TableName = '$(TableName)';
// create QVD
STORE $(TableName) INTO [$(QVDPath)$(TableName).qvd] (qvd);
// Drop de la table
DROP TABLE $(TableName);
NEXT;
You can also extend @Taoufiq_Zarra solution replacing the manually entered list of tables with SQLTables statement (SQLTables | Qlik Cloud Help) or doing a query to return the list of tables from your Database. This will give you a sequential ETL process, one table at time.
I personally prefer creating the 300 individual Script Apps in a specific Space and running all of Script Apps at the same time with an Automation. You can achieve that using one single QVS file and using the Script App Name as a variable to identify which table to load. Let me know if you are interested in this approach then I can detail that to you.
Regards,
Mark Costa
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
I went through this process a few months ago. The details of the solution described here are specific to tables stored in SQL Server, but I know that there are parallels for this in Oracle, and I suspect also in other database engines.
The overall process creates a view in the database to present column data, and a script (could be turned into a stored procedure, but I left it as a script) that creates a load script that I could paste into the Qlik data load editor. I created several analytical dashboard apps for this load. I put all of the load scripts for a specific database and schema into a single load script, so that I could load all of the "like data" together. You may have some other approach that you prefer.
Each time before you run the load script, edit the 4 variables in the top of the script.
@SourceSchema is the schema that contains the table in the database.
@TableName is the name of the table in the database.
@FilePrefix is a value that may be appended to the front of a field name. In the case of some of my databases, many tables had a single key field named: GUID. I wanted to prefix a value to the front of the this field name to that the Qlik engine would not automatically join all of the tables on this field name.
@SourceDatabase is the name of the database that contains the table of interest.
I found that once I had this script tuned for my database, it only took a couple of minutes to generate the load script for a table.
Now that Qlik supports an enhanced file/folder structure for data files, you may want to modify this script to support a more sophisticated file structure.
Note that on my on-premises Qlik installation, we also loaded dashboards from stored procedures. You can't load dashboards with stored procedures in Qlik Cloud, so I create agent jobs to run the store procedures and store the results into tables. I then loaded the tables to Qlik Cloud with this technique.
We also loaded dashboard from views. I have a similar script that I developed to load Qlik Cloud QVD files from views.
Having said all of that, Later versions of the data gateway support passing user credentials when loading data, so we no longer use a library of QVD files on Qlik Cloud. We load dashboards directly from our on-premises SQL Server database. The new Qlik tools inherited from Talend also have some cool ETL/ELT capabilities that might make your thoughts about creating a library of QVD data files obsolete.
You may also want to see my early (for my implementation of Qlik Cloud) rambling about data governance using QVD files here: Qlik-Cloud-Data-Integration/Qlik-Cloud-security-model-to-control-access-to-data
This procedure relies on a view into the database data dictionary that presents the fields of the tables as a table-like view. Here is the SQL Server specific code:
@Vikash2024 I hope you have list of table names stored somewhere so that you can loop over each table.
// list of table names
TableList:
Load TableName
FROM table;
for Each vTableName in FieldValueList('TableName')
[$(vTableName)]:
SQL SELECT *
FROM [database].[$(vTableName)];
Store [$(vTableName)] into lib://FolderConnection/QVD/$(vTableName).qvd(qvd);
Drop Table [$(vTableName)];
Next vTableName
Thanks Taoufiq..
Thanks Kushal...
what if table name come from the database.?
@Vikash2024 replace TableList load as database table
// Connect to database
LIB CONNECT TO 'sql_source';
// list of table names
TableList:
SQL SELECT TableName
FROM database.table_name;
for Each vTableName in FieldValueList('TableName')
[$(vTableName)]:
SQL SELECT *
FROM [database].[$(vTableName)];
Store [$(vTableName)] into lib://FolderConnection/QVD/$(vTableName).qvd(qvd);
Drop Table [$(vTableName)];
Next vTableName
It's working. thank it was really helpful.