Using control structures
Any basic development language will include some control structures to either repeat the execution of particular tasks or change what task will happen next based on conditions. QlikView is no different, so in this section we will examine the various options.
Branching with conditional statements
It can be enormously important to be able to execute different sets of statements based on different conditions. It gives us a lot of flexibility in implementing our solutions.
If … Then … ElseIf
If ... Then ... ElseIf
is a fairly fundamental construct in many programming languages. We test a condition, and if it is true, we execute one set of statements. If it isn't true, then we can either execute a different set of statements or perform a new test and keep going.
As an example, if we wanted to test whether a file exists before trying to load it:
If Alt(FileSize('c:\temp\Data.qvd'),0)>0 Then Data: Load * From c:\temp\Data.qvd (qvd); End if
Note
We use Alt
here because...