973-584-9100 contactus@bardess.com

This concept can be used in so many ways and can come in handy for complex situations. Essentially, with the use of dollar sign expansion, you can execute script you have programmatically built in the script or pulled in from source files.

Notice “$(vAnswer)” in the below example. It is going to be expanded by the dollar sign expansion and be executed like any other script.

script

Which returns:

script

Source

Now this is a fun and simple example, but not really practical. A more complex and practical example is loading script from external files and executing them on the fly.

Let’s say that the DBA team came to you and needs you to run a series of audit queries each day. However, this list of SQL queries will always be changing and the solution should be flexible. Is this something that Qlik can handle?

Of course! All we need to do is combine the tip covered in 101TIWIHKS – 85 with this concept.

script

This script will load the script from all of the SQL files in a folder. Then execute them, track the number of records returned by the query, and then store the individual results to a CSV file for the DBA team to analyze.

Source

}