When developing QlikView apps it is a good idea to develop standards that you adopt across all of your documents. A good way of ensuring these standards are followed is to use Include files in your load scripts.

QlikView Include files are snippets of code that are stored as text files outside of the QlikView app. Use of includes across multiple apps allows for effective code reuse.

Perhaps the most common use for include files is to store database connection details. By this simple route, when database credentials require changing they only need to be updated in the include file and all documents that use that include file would then automatically use the new credentials. An other potential advantage for this approach is to toggle easily between production and test database environments by having different include files on different servers.


Database connections however are just one example of the sort of code you can place in an include file.  Things that I have used them for in the past have included setting default variable values (such as storing RGB values) and calling a routine to log the performance of load scripts.

The point is that anything that can go into a load script can be placed into an include file.

The thing to watch though is, as with using dollar sign expanded variables, that the script executes as if all code is contained in one script. So if, for example, you commence a comment block within your include file (with a /* ), but neglect to close it, all subsequent code in your load script will effectively be commented out. As QlikView is not aware of the contents of your include file as the script is being edited; the syntax highlighting will not show the subsequent code as commented. This can be quite confusing – so be careful of this when using include files.

[Please note: see this subsequent blog post on resolving this]

Syntax highlighting is worth mentioning here, as due to your include file code being stored in a text file; QlikView is not able to do syntax highlighting for you. One way around this is to edit the code in QlikView first and then copy and paste this code into an include file afterwards. Alternatively, Matt Fryer has provided a syntax highlighting definition for Notepad++, which he has made freely available for download here.

So, after discussing the why’s of QlikView include files, here’s the how. You simply have to reference your text file in a dollar sign expansion, with the prefix “Include”.  Like this:

$(Include =..\includes\DBConnect.txt);

Note the use of the relative path (the ..\ ) which means that as long add the folder structure of the .txt file and .qvw remain together the files can be moved to a new location without anything breaking. Drive letters and UNC paths are both valid here also would you want to reference a fixed location.

Something to watch here is that QlikView will not raise an error if your include file is not found – it will simply continue without doing anything.  This can be confusing at best when the code you thought would run does not.

The use of the Debug functionality in QlikView is particularly useful when using include files. Each include file opens on a separate tab in the debugger so it is quite easy to spot what code had come from where and ensure it is indeed getting executed.

Hopefully that has given you what you need to start using include files. I’m sure if you do use them you will be able to save yourself some time and bring a greater degree of consistency to your QlikView apps.