Skip to main content
Alexander_Thor
Employee
Employee

As your QlikView deployment grows in size it can quickly get unwieldy unless you start imposing some sort of structure and standards to it.
In Computer Science we sometimes talk about Separation of concerns, http://en.wikipedia.org/wiki/Separation_of_concerns, although it is not 100% applicable for QlikView it does make sense to try to split the different pieces of a QlikView document apart into re-usable components.

To help you with that QlikView has the functions Include and Must_Include.

Essentially what this allows you to do is to create reusable snippets of load script that you can then re-use across your deployment. All of those connection strings to databases are prime candidates for a include statement, 1 statement that can be referenced from multiple documents and 1 place to change it when your connection string changes.

Connection strings are just one example, I've used it in the past to store the corporate graphical profile as variables that I can then include in all my documents or why not a standard calendar and date formats?

Our own Qlik Deployment Framework also heavily relies on Include statements to allow apps to be portable between different servers and to promote code re-use. You can join the QDF group here, QlikView Deployment Framework


So how do I use it?
To quote the help file,

$(Include =filename )
$(Must_Include =filename )

The include and must_include variables specify a file that contains text that should be included in the script. The entire script can thus be put in a file. This is a a user-defined variable.

The difference between include and must_include is that include will fail silently if the file is not found during script reload, while must_include will throw an error if the file is not found.

Examples:
$(Include=abc.txt);
$(Must_Include=def.txt);

We make use of dollar sign expansion to expand the contents of an external file into our load script.
The file path supports both absolute and relative paths making it ideal for portability between test and production servers.

If you ever were a fan of Inception then you could start structuring your Include statements with nested dollar sign expansions to manage where to load the Include files from,

let env = '<A absolute or relative file path, for example ..\Config\Test\>';
$(Include=$(env)\ConnectionString.txt)

This will also be my last post for the Design Blog, unless I make a guest appearance , so I hope you have enjoyed reading my posts as much as I have enjoyed writing them.

18 Comments
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

You can use a full UNC path (i.e. \\myserver\c$\myfile\).  Mapped drives can work, but often they exist for the developer but the service user that the Server runs as is not aware of them - so I would avoid these.

In order to use a script that is on a web server you would have to get a bit more clever - perhaps loading the file into a table then using a STORE to write the include file - but this is probably not a good idea.

Steve

2,278 Views
Not applicable

Hi Steve , thanks a lot for your help!

2,278 Views
mhappiee
Partner - Contributor III
Partner - Contributor III

Hi

what If in case we have multiples script files in text doc to be loaded in to QlikSense, How is that possible?

Ref to question I posted:Loading Script from multiple txt files to multiple tabs

Anand

0 Likes
2,286 Views
anderseriksson
Partner - Specialist
Partner - Specialist

How about multiple includes where you need it?
The include is just a simple text inclusion of the file content.

0 Likes
2,286 Views
mhappiee
Partner - Contributor III
Partner - Contributor III

Hi Anders

Thanks for the prompt Response

So you mean add include for every tab which will have multiple includes in the App script- not sure if that works, will try

So Qualifying/data massaging of  the script or modifying should be done only in the script (txt file) or post loading in to the Qlik, will I be able to do it like an incremental load?

The main objective is that I want to maintain sql script in the text doc and do modifications on that script post loading it to Qlik.

Thanks

Anand

0 Likes
2,286 Views
sspe
Creator II
Creator II

As Anders mention, you can just add the include statement everywhere you want to load a script part from a file. If you have all your SQL selects in seperate txt files, you can just load each of these files with the Include statement just like if you have written the SQL statement directly in your script.

That being said, then I'd be a little cautious in making extensive use of includes. There are no doubt that it will work, but the readability of the script in Qlikview will be very poor if to much happens in seperate script files. When you need to debug your script or later on make modifications, it's quite cumbersome to open too many txt files one by one to see what they are doing. I have a few older app's that have been made in that way (by some former consultants) and it's a real pain to figure out the business logic in these app's because I'll have to open a lot of txt files.

I agree it can be tempting to have a lot of scripts with your SQL statements that you are using in many different apps, because you then only have to modify it in one place. What I often find though, is that it's not that often you have that many apps that are so alike that this pays of in the end. Quite often you have to make minor changes any way and/or after you have modfied the txt file, you'll have to edit something in your app anyway.

Where I do find Include files useful, is to load some "standard" files like e.g. Date dimensions, Color code files, Variable files etc. Other than that, I'd in most cases prefer to have the SQL statements etc. directly in the script.

/Steen

0 Likes
2,286 Views
mhappiee
Partner - Contributor III
Partner - Contributor III

Oh, Let me give it a try and will reply back. Thanks or all the help Anders & Steen

0 Likes
2,286 Views
mhappiee
Partner - Contributor III
Partner - Contributor III

That helped Steen, Thanks a ton

0 Likes
2,286 Views