Introduction
The Peek() function works as a scripting function. The Peek() function returns the field value from a specific field in a table. By using the Peek() function you can specify the row number and table name that you want to extract in the script.
Use the following procedure to create a sample showing how to use a Peek() function in a QlikView application.
Step 1: Open the QlikView application
It is the first step, in this step you need to open the QlikView application then go to "File" -> "New" then this window will be opened.
Step 2: Open Edit Script
The second step is to open the edit script window from:
"File" -> "Edit Script".
- Then this window will be opened.
Step 3: Select Database
The third step is select the database from the data tab and click on the Connect Button.
Step 4: Data link property window
In this window we select the SQL Server and click on the Next Button.
Step 5: Connection tab
In the connection tab, you entered the server name and user name and password and selected the database from your server and click on Test Connection.
- Then you find that the test connection succeeded and click on the OK button.
- Then click on the OK button.
Step 6: SQL Server login
Then they require a SQL Server login so enter a valid login id and password and click on the OK button.
- Then this window will be opened.
Step 7: Create a select statement
When we click on the Select button on the data tab then this window will be opened.
- Then this window will be opened and click on the OK button.
Step 8: Code of edit script and use Peek() function
After login into the SQL Server, the edit script window will be opened and reload it and also use the Peek() function with a specific variable.
Step 9: Save QlikView file
After reloading the edit script, the next step is to save the QlikView file and click on the Save button.
Step 10: Script execution progress
Then the script execution progress window will be opened and will require a login Id and password and click on the OK button.
Step 11: Sheet property Window
After this process, the sheet property window will be opened. Add a field and select a field from the available fields and click on the OK button.
- Then this window will be opened.
Step 12: Select text object
Right-click anywhere in the blank sheet and select "New Sheet Object" -> "Text Object...".
Step 13: New text object
In this window, in the General tab you need to specify the variable in the text and click on the OK button.
Now here you can see, the maximum birth date will be shown that we declared in our database.
Step 14: Now again select another text object, right-click anywhere in the blank sheet and select, "New Sheet Object" -> "Text Object...".
- Then this window will be opened and click on the OK button.
Now here you can see, the minimum birth date will be shown that we declared in our database.
Step 15: Final window
In the final window you can see the maximum and minimum birth dates.
Summary
This article introduced the Peek() function and describes how the Peek() function selects a specific value from a specific field in a table.