Have you ever thought it might be interesting to store a Qlik data model into a single QVD? This can be useful in a number of cases such as:
- Archiving (and retrieving) data models.
- Overcoming the “single binary load” restriction.
QlikView Components (QVC) Version 11 introduced two new routines to do just that:
Qvc.ExportModel — Exports all tables of the current model into a single QVD.
Qvc.ImportModel — Import a data model created by Qvc.ExportModel.
Even if you don’t have QVC V11 installed, you can try Qvc.ExportModel right now using http include. Add these lines to any QlikView script (instructions for Qlik Sense further on down in this post).
Mind the wrap. The Must_Include should be on one line. Using QVC requires the Qvc.qvs library be included (usually at the beginning of script), CALLing Qvc routines, and CALLing a Cleanup routine at the end of your script.
Assuming this script is included in “Sales Dash.qvw”, the default exported model QVD will be named “Sales Dash.qvd” in the same directory.
Now, to import this QVD model into another qvw, replace the CALL to ExportModel in the above sample with:
CALL Qvc.ImportModel('Sales Dash.qvd')
The original model will be reconstructed as individual tables.
Qvc.ExportModel has three optional parameters:
|| String. Optional. Relative or absolute directory where the model QVD will be stored. If relative, it follows the same rules as the STORE script statement for relative directory.
|| String, Optional. Name for the model QVD. If omitted, the name of the QVW will be used. For example, if QVW is “Sales.qvw”, then QVD will be “Sales.qvd”.
|| String, Optional. 1/0 True/False. If True, a timestamp of the form _YYYYMMDDhhmmss will be appended to the QVD name. Default if omitted is False.
Qlik Sense has no default path so parameter #1, a lib:// for the QVD should be specified. Alternatively, if a lib has been established with a DIRECTORY statement, parameter 1 can be omitted.
Qlik Sense will require a web file Connection for the http Must_Include.
After defining the web connection and having an appropriate folder connection to store the QVD in, Qlik Sense script would look like this:
That’s all there is to it! If you are already using QVC, I hope you’ll find these routines a welcome addition to the library. If you are new to QC, explore more at QlikviewComponents.org.
Thanks to Jörgen Peerik for raising the single-QVD export idea during a QVC class.