As with every form of scripting, writing QlikView scripts carries with it the risk of introducing bugs and errors. In this section, we will look at some of the available options to find and solve bugs in your script.
Improper use of syntax is a common cause of errors. Fortunately, QlikView has a feature that will catch these errors as they happen: Syntax Check.
As we saw earlier, QlikView script has syntax highlighting. Whenever incorrect syntax is detected, the statement is underlined in a red squiggly from that point onward. In practice, this means that often the error was made in the line that appears before the red underlined text. The following screenshot shows a piece of script with a syntax error, see if you can see what the error is.
If you looked closely at the script in the previous picture, you will have noticed that there was a comma missing after the TableName column. This causes the statement to be underlined in red from that point onward.
Besides catching errors on-the-fly, we can also run a syntax check over the entire document by selecting Tools | Syntax Check from the menu, or by clicking the icon showing an arrow underlined in red, the right-most icon on the toolbar.
Saving logs to disk
When a reload is performed in QlikView, a log of all activity is shown in the Script Execution Progress window. A copy of this log can also be saved to disk so you can review it at a later time. If you haven't already set this up for the current example document, please follow these steps to generate log files:
Now, each time the script is run, an additional log file is created in the same folder as your QlikView document. The log file has the name of your document, with the date, time, and .log extension post fixed to it. For example Airline Operations. qvw. 2012_07_07_10_24_43. log.
The script debugger
The Debugger offers some handy features to troubleshoot issues in your QlikView script. We can open the Debugger window, shown in the following screenshot, by clicking on the icon labeled debug on the toolbar, or by selecting File | Debug from the menu.
Besides buttons that trigger the various actions, the debugger dialog contains, from top to bottom, the following areas:
We can run the script in the following different ways:
The statement that is currently being executed is marked with a yellow bar, in the preceding screenshot this can be seen on line 73.
The following functions within the debugger are noteworthy.
Breakpoints are used to pause execution of the script at a particular point so that the intermediate state of the environment can be inspected without having to Step through the entire script.
A breakpoint is represented by a red dot, which is added by clicking on the row number. The preceding screenshot shows a breakpoint on line 82. A single breakpoint is removed by clicking on it. We can remove all breakpoints by clicking on the Clear button.
With their long load times, debugging scripts that load a lot of data can be rather cumbersome. This is where the Limited Load option proves useful. When this option is checked, QlikView will, for each statement, only load the number of rows that are specified in the input box.
As a limited load does not load all data, it is important to note that lookups, mappings, and joins may not function correctly.
Another option that can be used to debug your scripts is the Trace statement. This statement is called from the script and can be used to write all sorts of (debug) information to the Script Execution Progress window.
For example, we can check if the amount of rows in the Aircraft Types changes after we add the left join command to the data from the Aircraft_Group.csv file to it. This is done by putting the following code before and after the statement.LET vNoOfRows = NoOfRows('Aircraft Types'); TRACE >>> Number of rows in Aircraft Types: $(vNoOfRows);
The first line of this script uses the No Of Rows() function to assign the value of the number of rows in the Aircraft Types table to the vNoOfRows variable. The second line uses the trace statement to write this value to the Script Execution Progress window.
The result is shown in the following screenshot; we can see that there are 369 rows before and after the left join statement, in the table.
Now that we have seen the various options for debugging our QlikView scripts, it is time to think about how to keep things tidy and understandable.
Qlik View Related Interview Questions
|Microstrategy Interview Questions||IBM Cognos Interview Questions|
|PL/SQL Interview Questions||MSBI Interview Questions|
|VBA For Excel Interview Questions||SAP BO Interview Questions|
|SQL Database Interview Questions||Qlik View Interview Questions|
|R Programming language Interview Questions||Pentaho Interview Questions|
|Advanced SAS Interview Questions|
Qlik View Tutorial
Seeing Is Believing
Data Modeling Best Practices
Basic Data Transformation
Set Analysis And Point In Time Reporting
Advanced Data Transformation
More On Visual Design And User Experience
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.