Re-using scripts
When developing QlikView documents, we often have to apply the same set of logic or transformations to different data. I have often observed QlikView developers taking a copy-paste approach for re-using a script. While this approach may initially work, it does make the script a lot harder to maintain. When something needs to be changed, you need to change it in each instance of the script, running the risk of different versions of the same transformation process.
In this section, we will look at two better approaches for re-using data. The first is the use of subroutines, which can be used to re-use script within an document. The second is the use of include files, which enables re-use of script between different documents.
Subroutines
A subroutine is a reusable block of script that can be called from other places in the QlikView script by using the CALL
statement. This block is formed using the SUB
and END SUB
control statements. Subroutines can contain parameters so that...