Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Moved to the cloud and would like to keep previous years data stored there and just query sql through the gateway for current year. Then combine the data for the application.
What is the best recommended way in the cloud to do this?
Thanks
I agree with @marksouzacosta that creating QVD partitions is a good strategy. Here's a simple step-by-step of how you can do this:
0. Assumptions
1. Create a new Sales subfolder in your space data files.
2. Add a Sales folder.
3. Create your QVD generator script.
// Initial QVD creation for previous years' data:
Lib Connect To 'Sales Database';
//// NOTE 1 ////
[Sales Years]:
Select Distinct
Date_Part('year', "sales_date") as "sales_year"
From "sales1"."sales";
//// NOTE 2 ////
Let vCurrentYear = Year(Today());
Trace #### vCurrentYear = $(vCurrentYear);
//// NOTE 3 ////
For Each vSalesYear In FieldValueList('sales_year')
//// NOTE 4 ////
If vSalesYear <> vCurrentYear Then
//// NOTE 5 ////
Let vNextSalesYear = vSalesYear + 1;
//// NOTE 6 ////
[sales_$(vSalesYear)]:
Select
*
From "sales1"."sales"
Where "sales_date" >= '$(vSalesYear)-01-01'
And "sales_date" < '$(vNextSalesYear)-01-01'
;
//// NOTE 7 ////
Store [sales_$(vSalesYear)] Into [lib://DataFiles/Sales/sales_$(vSalesYear).qvd](QVD);
//// NOTE 8 ////
Drop Table [sales_$(vSalesYear)];
End If
Next vSalesYear
Drop Table [Sales Years];Here are some notes on that script:
4. Run the script successfully once.
5. Create or open your sales app.
6. Go to the Data Load Editor and add this to a new script section:
Let vCurrentYear = Year(Today());
Trace #### vCurrentYear = $(vCurrentYear);
[sales]:
Load
*
From [lib://DataFiles/Sales/sales_*.qvd]
(QVD);
Lib Connect To 'Sales Database';
Concatenate ([sales])
Select
*
From "sales1"."sales"
Where "sales_date" >= '$(vCurrentYear)-01-01'
;This script loads all of the sales QVDs we stored in the previous step by utilizing the asterisk as a wildcard. We then pull all sales data from our sales table where the sales_data column is in the current year, which is immediately concatenated into the table we loaded from our QVDs. The end result is all of our sales data.
Some notes
Hi @dwighttrumbower,
There are multiple ways to solve this problem.
One solution is to move your historical data to Qlik Cloud, simple uploading your historical data and naming it accordingly: Example: sales_historical.qvd.
Next, your regular ETL App will load your data from SQL and store as sales.qvd (depending on your data you can do data partitions like sales_2025.qvd, sales_2024.qvd or even sales_202512.qvd, sales_202511.qvd, etc).
Your Dashboard Layer, or even a Layer 2 QVD Builder App, will just combine those records: Example:
[Sales]:
LOAD * FROM [$(yourLibraryAndFolder)sales_*.qvd](qvd);
Regards,
Mark Costa
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
Do I have to build some type of ETL app to do this?
If it is a one-time thing, you don't need to do any ETL app. Just upload the QVD file straight to your Qlik Cloud Tenant:
Regards,
Mark Costa
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
Well, one would have to create the QVD.
I agree with @marksouzacosta that creating QVD partitions is a good strategy. Here's a simple step-by-step of how you can do this:
0. Assumptions
1. Create a new Sales subfolder in your space data files.
2. Add a Sales folder.
3. Create your QVD generator script.
// Initial QVD creation for previous years' data:
Lib Connect To 'Sales Database';
//// NOTE 1 ////
[Sales Years]:
Select Distinct
Date_Part('year', "sales_date") as "sales_year"
From "sales1"."sales";
//// NOTE 2 ////
Let vCurrentYear = Year(Today());
Trace #### vCurrentYear = $(vCurrentYear);
//// NOTE 3 ////
For Each vSalesYear In FieldValueList('sales_year')
//// NOTE 4 ////
If vSalesYear <> vCurrentYear Then
//// NOTE 5 ////
Let vNextSalesYear = vSalesYear + 1;
//// NOTE 6 ////
[sales_$(vSalesYear)]:
Select
*
From "sales1"."sales"
Where "sales_date" >= '$(vSalesYear)-01-01'
And "sales_date" < '$(vNextSalesYear)-01-01'
;
//// NOTE 7 ////
Store [sales_$(vSalesYear)] Into [lib://DataFiles/Sales/sales_$(vSalesYear).qvd](QVD);
//// NOTE 8 ////
Drop Table [sales_$(vSalesYear)];
End If
Next vSalesYear
Drop Table [Sales Years];Here are some notes on that script:
4. Run the script successfully once.
5. Create or open your sales app.
6. Go to the Data Load Editor and add this to a new script section:
Let vCurrentYear = Year(Today());
Trace #### vCurrentYear = $(vCurrentYear);
[sales]:
Load
*
From [lib://DataFiles/Sales/sales_*.qvd]
(QVD);
Lib Connect To 'Sales Database';
Concatenate ([sales])
Select
*
From "sales1"."sales"
Where "sales_date" >= '$(vCurrentYear)-01-01'
;This script loads all of the sales QVDs we stored in the previous step by utilizing the asterisk as a wildcard. We then pull all sales data from our sales table where the sales_data column is in the current year, which is immediately concatenated into the table we loaded from our QVDs. The end result is all of our sales data.
Some notes