Académique Documents
Professionnel Documents
Culture Documents
This book is dedicated to my son Rohan, my nephew Tanuv who being just 9.5 years has started
with CSS3, HTML and JavaScript, my wife Radhika and my parents and well wishers. This book is
also dedicated to all the participants who attended my QlikView training and has given some really
constructive feedback based on which this series of books have been structured.
Contents
Chapter 0 - Agenda . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1 - Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3 - Developer Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10
12
12
17
23
24
25
25
26
29
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Chapter 0 - Agenda
Lets quickly glance through the table of content in a nutshell.
SECTION 1 - QlikView Developer
Introduction
QlikView Development Methodology
Data and Scripting
Connect, Select and Load
Loading Data from SQL Server
Executing Stored Procedures
Reading XML Data from SQL Server
Green, White and Gray
The Magic of Preceding Load
Associations
Loading Data from XML file
Loading Data from Excel and CSV files
Data Modelling Issues
Referencing external files
Basic Data Transformation
Data generation in the QlikView script
Scripting Best Practices
Master Calendar
Mapping Tables
Data Model Optimization
Link Tables
Interval Match
Cross Tables
Advanced Calculations
Alternate States
Set Analysis
Metadata
Generating QVDs
QlikView Security
Additional Load Types
How to use QlikView Extensions
Chapter 0 - Agenda
Performance Tuning
SECTION 2 - Programming for QlikView Ninjas
SECTION 3 - Advanced Development
SECTION 4 - QlikView Designer
SECTION 5 - Basic Server Administration
1 - Introduction
Welcome to the QlikView for Ninja series of book. This book will be a handy step by step
introduction to most of the QlikView features that will help you become a better QlikView
Developer. This book is in early access mode and chapters will be published every week. Also,
the readers constructive feedback, will help form the structure of the book as well apart from the
core agenda.
QlikView is a Guided Analytical BI tool developed by QlikTech(now Qlik).
QlikView is more of a business discovery platform. It helps you find data quickly and get out meaning
from it to make efficient and quick decisions with minimum support from the developer team.
Though mostly the business user or the end user can directly work with QlikView but for efficient
administration and management the support of the IT team is required.
Also, QlikView is one of the foremost in memory analytics, i.e. everything, all data, including filters
eveything is stored in RAM once the document is loaded. This makes it very fast from user experience
perspective. Also, with more power comes more responsibilities(remember the Spiderman movie).
The application needs to be tuned as it scales and many aspects of performance needs to be taken
into account beginning from chart optimization, data model design, server configurations, user loads
etc.
Associative Technology
How QlikView refers from other BI products the associative user experience. Traditional BI tools
has a fixed navigation path to explore data, but in QlikView, you can start any where, any column
or field and this gives your mind more opportunity to explore and deduce meanings from data.
The below diagram visualizes the two experiences.
1 - Introduction
1 - Introduction
The below figure depicts a simplified view of QlikView deployment diagram containing the products
that take part in the deployment.
1 - Introduction
QLIKVIEW DESKTOP
The QlikView Desktop is a windows based desktop tool that is used by developers and business
analysts to create data models and to build the graphical user interface for QlikView apps. This is
the swiss army knife for the QlikView developer and Designer who can use all the features to create
robust data model and a very efficient user interface for the clients. All the scripting is done through
this application.
The file type that is created using the QlikView Desktop is known as QVW (.qvw or QlikView file).
One can also create a readonly QVD (QlikView data) file, which is a format which QlikView uses to
store its compressed data.
QLIKVIEW SERVER (QVS)
The QVS is a server product that contains the in-memory analytics engine. The QVS handles all
client/server communication between a QlikView client (i.e. desktop, AJAX, IE plugin or Mobile) and
the server. It includes a management environment i.e QlikView Management Console for providing
administrator access to control all aspects of the server deployments including security, distribution,
clustering, authorization etc) and also included a web server to provide front-end access to the
documents within.
The web servers user portal is known as Access Point. Also, its important to note that while
QVS contains its own web server, once can also utilize Microsoft IIS (Internet Information Sever) for
1 - Introduction
this purpose as well. The QVS handles client authorization against existing directory providers like
Microsoft Active Directory, LDAP etc and also performs read and write to ACLs (Access Control
lists) for QVW documents.
QLIKVIEW PUBLISHER
The QlikView Publisher is also a server-side product that performs two important functions:
1. It is used to load data directly from data sources defined via connection strings in the QVW
files.
2. It is also used as a distribution service to reduce data and applications from source QVW file
based on various rules, such as user authorization or data access privileges (these rules are
based on fields from the data model) and to distribute these newly-created documents to the
appropriate QlikView servers or static PDF reports via email.
QlikView publisher is not a mandatory server component though, but is useful for large scale
enterprises. When QlikView Server is installed the publisher component is also installed, but it is
only activated when the publisher license is enabled in the QlikView Management Console.
** How QlikVIew Works: A peek under the covers **
When a QlikView document is published to a QlikView Server, the content it contains become
available for consumption by any user with the required privileges to access it. The flow is outlined
below:
When a user first opens a QlikView document, data is loaded in memory (server memory).
The compressed and unaggregated dataset is loaded from the disk into QlikView Servers
RAM. This in-memory repository serves as the based dataset for this initial user and all other
users requesting the same document. This repository stays in memory until no user activity
has occurred within a defined time-out period.
Users explore data via selections. The concept of user defined selection state is central to
QlikVIew. As user clicks around in a QlikView document trying to demystify the maze of
data, they indicate which subsets of data they are interested in analyzing and which subsets
should be ignored. QlikView takes advantage of the highly indexed nature of the unaggregated
dataset. QlikView dynamically presents a subset of all the data available to the QlikView
document based on the selection state. This happens in real time.
Upon selection, aggregates render instantly. On the fly, QlikView renders aggregates as
intuitive and interactive user interface objects via, charts, graphs, tables, listbox etc. Users
interact with objects in QlikView documents through any supported client. Also users can
create their own objects using collaboration features of QlikView.
We will have a look at how data is structured in QlikView memory model in later
chapters.
2 - QlikView Development
Methodology
Each and every company and may be individuals have their own development methodology.
Now QlikView doesnt put a hard and fast rule as to what kind of methodology works, but its
recommended to go with any kind of agile methodology to get the most from the project in time
and budget.
Irrespective of the selection of any specific methodology, some coding practics and development
guidelines needs to be strictly followed to get optimum result These practices are spread across the
following major activities.
Scripting Guidelines
Requirements Gathering,
Understanding the key metrics and KPIs
Source control integrations
Understanding the source data et el.
We will cover these topics incrementally over the next series of chapters.
3 - Developer Roles
For any successful QlikView implementation it is very essential to have the correct team structure.
This team structure could compose of single person to start with but eventually for all different roles
there could be specialist appointed.
Lets look at roles available in any QlikView implementation.
The QlikView team structure consist primary of a backend developer, a designer, a visualization
expert and an administrator. Each and every role has its own responsibility, but as I said, when you
are starting up with QlikView implementation, may be a single person could be playing all the roles.
But as you move forward into the project, a dedicated team needs to be setup to deal with the chores
of each roles.
A successful implementation consist of a fine mixture of the above roles. The responsibilities of each
role is outlined below.
The various roles are summarized the the below table.
11
3 - Developer Roles
Role
Description
Developer/BA
Designer/BA
Visualization
Admin
Business User
13
Snowflakes on the other hand more of a relational strucute, in which the dimension tables are not
fully merged.
14
The general rule of thumb is to use star schema for analysis purpose and snowflake schema for
transactional database.
We will be build a data model that initially represents the first figure below and then through data
modelling activities we will make the model look as in the second figure.
Figure : 1
15
Figure : 2
Wishing you best in your data modelling adventures and we will use many of the ninja like tools to
achieve our end objective.
At any point you can press Ctrl+T to bring up the table viewer in QlikView. Table
viewer is a handy tool that shows the struture of tables laid out in QlikViews memory.
It shows both the source structure and the internal table structure. We will use the
internal table structure view for troubleshooting most of our data modelling issues.
AdventureWorks Sample Database
https://msftdbprodsamples.codeplex.com/releases/view/55330
16
2. You will be greeted with the Getting started wizard. Close this by clicking on th X button
or by pressing the ESC key.
18
3. The next thing to do then is to save this document. QlikView will automatically add the file
extension as .qvw.
4. Open up the Script Editor by clicking on the Edit Script toolbar or by pressing the Ctrl+E
key on your keyboard. The following screen will show up.
5. Create a new tab by clicking on the Tab menu and then click on Add Tab and enter a
friendly name.
19
6. Click on the Relative Path check box and then click on the Table Files and select the
special_offer.xlsx.
7. You will be presented with the File Wizard:Type dialog. Look at the File Type section on
left side. The file type Excel(xlsx) should be automatically selected.
20
8. Click on the Finish button for now and the following screen should be presented to you.
9. Click on the Reload toolbar menu to load the data into QlikView. You will get a progress
dialog, which will be automatically closed or you have to manually close based on User
10. On the subsequent screen click on Add All and then click on OK.
21
22
11. The following will be the output of your hard labour. (Dont despair, this will get better). Click
on Layout menu and then click onRearrange Sheet Objects.
Dont worry about how things are related. We will talk about relations in detail. For now
understand that if the name of the field matches, QlikView creates an association between the tables
automatically.
Lets dissect each of the above elements. In any way the above elements doesnt represent the entire
thing, but
they form the most important part from the whole.
25
Variables
Variables are placeholders in memory. They hold whatever value (number, strings, date) you put in
them. You can
set a variable to a specific value and also read values from them. In QlikView there are two ways to
define a variable, by SET and LET statement.
SET statement can be used to define variables for lazy evaluation, i.e. variables assigned with SET
is not immediately evaluated and is stored as is. This is useful for substituting strings, paths, drives,
evaluating formulas
etc.
SET x = 3 + 2;
In the above statement the variable is evaluated as 3 + 2.
The LET statement on the other hand evaluates whatever is on the right hand side and store the
result in the variable.
For e.g.
SET y = 2 + 2;
In the above statement y contains the value 4.
Variables are a very powerful construct in QlikView (rather any programming environment). It
is variable that makes the system dynamic. You can change the behaviour of the application by
changing the variables. We will be heavily using variables when creating master calendars, qvd
generators, in reusing expressions, even multilingual design etc.
Loop
A loop represents repetition in the program. Loop is yet another powerful construct in any
programming environment. This helps us maintain our program/script and keep it small by avoiding
repetition. A loop executes so long as the condition defining the loop is met. There are various ways
in which loops can be defined. Lets examine one at a time.
The do..loop control statement is a script iteration construct which executes one or several statements
until a logical condition is met. The syntax is:
do[ ( while | until ) condition ] [statements]
[exit do [ ( when | unless ) condition ] [statements]
loop[ ( while | until ) condition ]
Where:
condition
26
Though the above program does nothing apart from looping 9 times, but the concepts can be applied
to any area. Inside the loop you can load files, create variables, automate script creation etc.
For..Next
The for..next control statement is a script iteration construct with a counter. The statements inside
the loop enclosed by for and next will be executed for each value of the counter variable between
specified low and high limits. The syntax is:
for counter = expr1 to expr2 [ step expr3 ]
1
2
3
4
5
27
[statements]
[exit for [ ( when \| unless ) condition ]
[statements]
next[counter]
Where:
counter is a variable name. If counter is specified after next it must be the same variable name as
the one found after the corresponding for.
expr1 is an expression which determines the first value of the counter variable for which the loop
should be executed.
expr2 is an expression which determines the last value of the counter variable for which the loop
should be executed.
expr3 is an expression which determines the value indicating the increment of the counter variable
each time the loop has been executed.
condition is a logical expression evaluating to true or false.
statements is any group of one or more QlikView script statements.
The expressions expr1, expr2 and expr3 are only evaluated the first time the loop is entered. The
value of the counter variable may be changed by statements inside the loop, but this is not good
programming practice.
If an exit for clause is encountered inside the loop, the execution of the script will be transferred to
the first statement after the next clause denoting the end of the loop. An exit for clause can be made
conditional by the optional use of a when or unless suffix.
Since the for..next statement is a control statement and as such is ended with either a semicolon or
end-of-line, each of its three possible clauses (for..to..step, exit for and next) must not cross a line
boundary.
** Exercise: Loading variables defined in excel**
Lets create variables dynamically which is defined in excel. Later on we will see how to extend this
functionality.
For this use the file variables.xmls in the datasource folder.
Look at the figure below for the code. The full code in text format is given at the end of this section.
28
29
Directory;
VariableTable:
LOAD VariableName,
VariableValue
FROM
DataSources\variables.xlsx
(ooxml, embedded labels, table is Variables);
If..then..elseif..else..end if
The if..then control statement is a script selection construct forcing the script execution to follow
different paths depending on one or several logical conditions. The syntax is:
1
2
3
4
5
6
7
8
9
10
11
if condition then
[ statements ]
{ elseif condition then
[ statements ] }
[ else
[ statements ] ]
12
13
1
2
3
4
5
6
30
end if
Where:
condition is a logical expression which can be evaluated as true or
false.
statements is any group of one or more QlikView script statements.
Since the if..then statement is a control statement and as such is ended with either a semicolon or
end-of-line, each of its four possible clauses (if..then, elseif..then, else and end if) must not cross a
line boundary.
** Exercise: Lets only do an actual reload of the document only if the reload parameter is set in
reloadflag.txt file **
The reloadflag.txt file can be found in the DataSources folder. In actual case, this file may be stored
in a remote accessible shared location.
31
Line 17 Trace simply outputs whatever is feeded to it. This can be viewed in the Script Execution
Progress Dialog.
Line 19 check whether the reload value of the reload variable after coverting it to upper case is equal
to FALSE.
Line 20 Will exit the script if Line 19 statement is evaluated to true (reload is false)
NOTE: Sometimes the Script Execution Progress Dialog just closes of automatically after the reload.
You can change this behaviour by setting the Keep Progress Open After Reload value checked in
the Settings->User Preferences menu.
Here is the full code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[ReloadFlag]:
First 1
LOAD *
FROM
DataSources\reloadflag.txt
(txt, codepage is 1252, no labels, delimiter is '\t', msq);
LET reload = Peek('@1',0,'ReloadFlag');
// Just for troubleshooting.
rogress Dialog
TRACE reload;
if upper(reload) = 'FALSE' then
exit Script
end if