Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Agenda
BASIC OF QLIKVIEW
SCRIPTING---------------------------------------------- BUILDING YOUR DATA
MODEL----------------------------------------------- TEA BREAK /
EMAILS----------------------------------------------------------- ALL ABOUT
QVDS--------------------------------------------------------------- THE LOAD
STATEMENT-------------------------------------------------------- CONCATENATION &
JOINS----------------------------------------------------- LUNCH BREAK /
EMAILS------------------------------------------------------- FUNCTIONS IN
QLIKVIEW----------------------------------------------------- STRING
MANIPULATION
AND MATHEMATICAL
Copyright
2013 Accenture
All Rights Reserved.
Copyright
2013 Accenture All Rights Reserved.
FUNCATIONS--------
09:00
AM
09:15
AM
09:15
AM
10:00
AM
10:00
AM
10:30
AM
10:30
AM
11:00
AM
11:00
AM
11:10
AM
11:10
AM
12:30
PM
12:30
AM
01:30
PM
01:30
PM
03:00
2
PM
03:00
PM
03:30
PM
Agenda
BASIC OF QLIKVIEW
SCRIPTING---------------------------------------------- BUILDING YOUR DATA
Introduction of Qlikview Script
MODEL----------------------------------------------- TEA BREAK
/
Connect
to the data sources
EMAILS----------------------------------------------------------- ALL ABOUT
QVDS--------------------------------------------------------------- THE LOAD
STATEMENT-------------------------------------------------------- CONCATENATION &
JOINS----------------------------------------------------- LUNCH BREAK /
EMAILS------------------------------------------------------- FUNCTIONS IN
QLIKVIEW----------------------------------------------------- STRING MANIPULATION AND MATHEMATICAL
Copyright 2013 Accenture All Rights Reserved.
FUNCATIONS-------Copyright
2013 Accenture All Rights Reserved.
09:00
AM
09:15
AM
09:15
AM
10:00
AM
10:00
AM
10:30
AM
10:30
AM
11:00
AM
11:00
AM
11:10
AM
11:10
AM
12:30
PM
12:30
AM
01:30
PM
01:30
PM
03:00
3
PM
03:00
PM
03:30
PM
Script
Qlikview
4
Now
Andthe
theQuestion
answer isis
XML tables
HTML tables
SCRIPT EDITOR
HOW ?
ool pane has four tab pages containing functions for script generation:
ata, Functions, Variables and Settings.
Tab: Within the Data tab, there are three grouping sections giving you
the control and functionality for bringing data into the QlikView document.
base grouping
ommands in the Database group are used to create a connection to a database
elect fields from a data source.
ect : Use this button to open the Data Link Properties dialog box
o select an OLE DB or ODBC data source and generate the appropriate connect
statement in load script
e Paths :
nable this option if the data location is relative to or along the same path as
rrent working directory. Otherwise, it will default to absolute or the alternative path for sta
ated in the scripts.
P:
Mark this check box for the ability to select files from an ftp file server
you request Table Files, QlikView Files or Include script statements.
Files . :
Launches the Open Local Files dialog box listing various test file formats including
oft Excel (.xls, xlsx) and QlikView Data (.qvd) files. Selecting one or several files and pressi
nerate one or several LOAD statements based on the options selected in the wizard.
10
w File :
on the this button to open the Open QlikView File dialog box listing QlikView files (*.qvw).
ng a file and pressing OK will generate a binary statement.
ne binary statement is allowed in a QlikView load script and
be the first statement in the load script
es :
ns the Table Files Wizard: Source dialog box to enter a URL as a source for your data table.
ata :
ns the Files Wizard on the Source page where you can load the contents of an already load
11
12
13
14
Lets create
one
Qlikview Demo
application
15
Agenda
BASIC OF QLIKVIEW
SCRIPTING---------------------------------------------- BUILDING YOUR DATA
MODEL----------------------------------------------- Introduction to Qlikview data model
TEA BREAK /
Star Schema vs Snowflake Schema
EMAILS------------------------------------------------------------
Synthetic Key
ALL ABOUT
Circular reference
QVDS--------------------------------------------------------------- Best Practices & QA
THE LOAD
STATEMENT-------------------------------------------------------- CONCATENATION &
JOINS----------------------------------------------------- LUNCH BREAK /
EMAILS------------------------------------------------------- FUNCTIONS IN
QLIKVIEW----------------------------------------------------- STRING MANIPULATION AND MATHEMATICAL
Copyright 2013 Accenture All Rights Reserved.
FUNCATIONS-------Copyright
2013 Accenture All Rights Reserved.
09:00
AM
09:15
AM
09:15
AM
10:00
AM
10:00
AM
10:30
AM
10:30
AM
11:00
AM
11:00
AM
11:10
AM
11:10
AM
12:30
PM
12:30
AM
01:30
PM
01:30
PM
03:00
16
PM
03:00
PM
03:30
PM
17
18
Star Schema
Ease of maintenance /
change:
Ease of Use:
Query Performance:
Type of Datawarehouse:
Joins:
Fewer Joins
Dimension table:
When to use:
Normalization/
De-normalization:
Synthet
ic Key
20 Synthetic
Key.qvw
21
22
FactBudget:
LOAD
Month,
Month & Year AS MonthYear,
Year,
BudgetAmount
BudgetAmount
FROM FactBudget;;
FROM FactBudget;;
23
FactSales ::
LOAD
TransId,
Month,
Year,
SalesAmount
FROM FactSales;
Concatenate
FactBudget:
LOAD
TransId,
Month,
Year,
BudgetAmount
FROM FactBudget;;
FactBudget:
LOAD
TransId,
Month,
Year,
BudgetAmount
FROM FactBudget;;
24
FactBudget:
LOAD
TransId,
Month & _ &
Month,
Year AS LinkKey,
Year,
BudgetAmount
BudgetAmount
FROM FactBudget;;
FROM FactBudget;;
26
Remove
27 Synthetic Key.qvw
Circulare
Reference.qvw
29
31
32
Agenda
BASIC OF QLIKVIEW
SCRIPTING---------------------------------------------- BUILDING YOUR DATA
MODEL----------------------------------------------- TEA BREAK /
EMAILS----------------------------------------------------------- What is QVD ?
ALL ABOUT
How to create & use QVD ?
QVDS---------------------------------------------------------------
and un-optimized QVD
THE LOAD Optimized
load
STATEMENT--------------------------------------------------------- Best Practices & QA
CONCATENATION &
JOINS----------------------------------------------------- LUNCH BREAK /
EMAILS------------------------------------------------------- FUNCTIONS IN
QLIKVIEW----------------------------------------------------- STRING MANIPULATION AND MATHEMATICAL
Copyright 2013 Accenture All Rights Reserved.
FUNCATIONS-------Copyright
2013 Accenture All Rights Reserved.
09:00
AM
09:15
AM
09:15
AM
10:00
AM
10:00
AM
10:30
AM
10:30
AM
11:00
AM
11:00
AM
11:10
AM
11:10
AM
12:30
PM
12:30
AM
01:30
PM
01:30
PM
03:00
33
PM
03:00
PM
03:30
PM
34
35
FactSales ::
LOAD
TransId,
SalesMonthYear,
SalesAmount
FROM [D:\Training\QVD\FactSales.QVD] (qvd);
36
37
$(vTable)::
LOAD
TransId,
SalesMonthYear,
SalesAmount;
SQL SLECT * FROM Sales;
STORE $(vTable) INTO $(vTable).qvd;
38
39
Agenda
BASIC OF QLIKVIEW
SCRIPTING---------------------------------------------- BUILDING YOUR DATA
MODEL----------------------------------------------- TEA BREAK /
EMAILS----------------------------------------------------------- ALL ABOUT
Introduction to LOAD Statement
QVDS---------------------------------------------------------------- Syntax of LOAD statement
THE LOAD
STATEMENT-------------------------------------------------------- CONCATENATION &
JOINS----------------------------------------------------- LUNCH BREAK /
EMAILS------------------------------------------------------- FUNCTIONS IN
QLIKVIEW----------------------------------------------------- STRING MANIPULATION AND MATHEMATICAL
Copyright 2013 Accenture All Rights Reserved.
FUNCATIONS-------Copyright
2013 Accenture All Rights Reserved.
09:00
AM
09:15
AM
09:15
AM
10:00
AM
10:00
AM
10:30
AM
10:30
AM
11:00
AM
11:00
AM
11:10
AM
11:10
AM
12:30
PM
12:30
AM
01:30
PM
01:30
PM
03:00
40
PM
03:00
PM
03:30
PM
File Wizard : You can open this wizard by clicking Table Files.. button
from script editor.
Table All
Wizard
: You can open this wizard by clicking Select..
button from
Copyright 2013 Accenture
Rights Reserved.
41
Copyright
Accenture All Rights Reserved.
script 2013
editor.
42
Agenda
BASIC OF QLIKVIEW
SCRIPTING---------------------------------------------- BUILDING YOUR DATA
MODEL----------------------------------------------- TEA BREAK /
EMAILS----------------------------------------------------------- ALL ABOUT
QVDS----------------------------------------------------------------
Introduction
THE LOAD
Forced Concatenation
NoConcatenation
STATEMENT--------------------------------------------------------- Scenario (Best use of Concatenation)
CONCATENATION &
Introduction to JOINs
JOINS----------------------------------------------------- KEEP Statement
LUNCH BREAK /
EMAILS------------------------------------------------------- FUNCTIONS IN
QLIKVIEW----------------------------------------------------- STRING MANIPULATION AND MATHEMATICAL
Copyright 2013 Accenture All Rights Reserved.
FUNCATIONS-------Copyright
2013 Accenture All Rights Reserved.
09:00
AM
09:15
AM
09:15
AM
10:00
AM
10:00
AM
10:30
AM
10:30
AM
11:00
AM
11:00
AM
11:10
AM
11:10
AM
12:30
PM
12:30
AM
01:30
PM
01:30
PM
03:00
43
PM
03:00
PM
03:30
PM
Concatenation.qvw
44
Budg
et
Amou
nt
1500
2500
Forced45concatenation.qvw
Brad
Isaac AM
SSE
NoConcatenate
[New Employee]
LOAD
Id,
Name,
Position
FROM
[New Employee].qvd(QVD);
New Employee
I
Nam Positi
d e
on
3
Brad
SSE
Isaac AM
46NoConcatenation.qvw
47
48
49
50
Table 1:
LOAD
A,
B,
C
FROM
Table1.qvd(QVD);
Table 1:
LOAD
A,
B,
C
FROM
Table1.qvd(QVD);
JOIN
INNER JOIN
LEFT JOIN
LOAD
A,
B,
C
FROM
Table2.qvd(QVD);
LOAD
A,
B,
C
FROM
Table2.qvd(QVD);
LOAD
A,
B,
C
FROM
Table2.qvd(QVD);
51
Table 1:
LOAD
A,
B,
C
FROM
Table1.qvd(QVD);
Table 1:
LOAD
A,
B,
C
FROM
Table1.qvd(QVD);
RIGHT JOIN
OUTER JOIN
LOAD
A,
B,
C
FROM
Table2.qvd(QVD);
LOAD
A,
B,
C
FROM
Table2.qvd(QVD);
52
}
53
54
Agenda
BASIC OF QLIKVIEW
SCRIPTING---------------------------------------------- BUILDING YOUR DATA
MODEL----------------------------------------------- TEA BREAK /
EMAILS----------------------------------------------------------- ALL ABOUT
QVDS--------------------------------------------------------------- THE LOAD
STATEMENT-------------------------------------------------------- ApplyMap()
CONCATENATION
&
MapUsing
JOINS----------------------------------------------------- IntervalMatch()
CROSSTABLE()
LUNCH BREAK
/
EMAILS------------------------------------------------------- FUNCTIONS IN
QLIKVIEW----------------------------------------------------- STRING MANIPULATION AND MATHEMATICAL
Copyright 2013 Accenture All Rights Reserved.
FUNCATIONS-------Copyright
2013 Accenture All Rights Reserved.
09:00
AM
09:15
AM
09:15
AM
10:00
AM
10:00
AM
10:30
AM
10:30
AM
11:00
AM
11:00
AM
11:10
AM
11:10
AM
12:30
PM
12:30
AM
01:30
PM
01:30
PM
03:00
55
PM
03:00
PM
03:30
PM
FUNCTIONS IN QLIKVIEW
> 1) ApplyMap()
ApplyMap is a lookup or mapping function in Qlikview. This function would lookup
KeyValue into lookup / Mapping table and replace it with the key in the existing
table.
So before exploring Applymap() function we have to first understand Mapping
Tables
By prefixing the LOAD statement with the MAPPING statement, we tell QlikView
that we want to create a mapping table. This is a specific type of table that has
the
following properties:
It can only have two columns, the first being the lookup value and the second
being the mapping value to return.
Map_Status:
Mapping
It is a temporary table. At the end of
the script, QlikView automatically
LOAD
removes the table from the data model.
StatusId,
Status
FROM
Status.qvd(QVD);
56
FUNCTIONS IN QLIKVIEW
> 1) ApplyMap() (Contd..)
We then used the ApplyMap() function to look up the key value while loading the
table.
The ApplyMap() function uses three parameters:
The name of the mapping table to use
The search value, a field value or expression from the source table, that is
looked up in the mapping table.
An optional value that specifies what value to use when no match is found in
the mapping table; here we used the value Unknown. When no value is
specified, the search value is returned.
Event:
LOAD
EventId,
APPLYMAP(Map_Status,EventStatusId,No Status) As EventStatus
FROM Status.qvd(QVD);
57
ApplyMap.qvw
FUNCTIONS IN QLIKVIEW
> 2) MapUsing
Map..using is statement similar to APPLYMAP() function which would replace key
with its respective key value from lookup / mapping tables.
It is useful when we have multiple key fields with the same name so instead of
writing APPLYMAP() function each and every time you can define this statement
for that Key field at the beginning of table load but after declaration on mapping
table.
In our previous example , suppose there are two more tables which StatusId
key field and need to replace with respective status from Map_Status then you
can write below statement
MAP Status USING Map_Status;
Event:
LOAD
EventId,
EventStatusId AS Status
FROM Status.qvd(QVD);
58
Map Using.qvw
FUNCTIONS IN QLIKVIEW
> Best practices
Always create separate tab Mapping tables and write all mapping table script
there
Always add prefix Map_ while providing name to the mapping table.
Use Map..using instead of APPLYMAP() whenever possible
Provide Default value in APPLYMAP() function
UPPER case your key in mapping table as well as in table.
59
FUNCTIONS IN QLIKVIEW
> Question & Answer
Suppose source tables are like :
Countr
yId
Country
Sales
Id
Countr
yId
Amou
nt
US
United
States
S1
US
100
S2
UK
200
UK
United
S3
JP
300
Kindom
Then
, What would be the output of below script ?
IN tell me
India
Map_Country:
Mapping
LOAD
UPPER(CountryId) AS CountryId,
Country
FROM Country.qvd(QVD);
60
FUNCTIONS IN QLIKVIEW
> Question & Answer
Suppose source tables are as below
Countr
yId
Country
Sales
Id
Countr
yId
Amou
nt
US
United
States
S1
US
100
S2
UK
200
United
Kindom
S3
JP
300
UK
Then
, What
would be the output of below script ?
IN tell me
India
Output
would
be
Map_Country:
MAP Country
Sales CountryId
Amou USING Map_Country;
Mapping
Event:nt
Id
LOAD
LOAD
S1
United
100
UPPER(CountryId) AS CountryId,
SalesId,
States
Country
UPPER(CountryId) AS Country,
S2
United Amount200
FROM Country.qvd(QVD);
Kindom FROM Sales.qvd(QVD);
S3
Copyright 2013 Accenture All Rights Reserved.
Copyright 2013 Accenture All Rights Reserved.
JP
300
61
FUNCTIONS IN QLIKVIEW
> IntervalMatch()
A common problem in business intelligence is when you want to link a number to
a range. It could be that you have a date in one table and an interval a From
date and a To date in another table, and you want to link the two tables. In
SQL, you would probably join them using a BETWEEN clause in the comparison.
But how do you solve this in QlikView, where you should avoid joins?
Typically, you would first load the table with the individual numbers (The Events),
then the table with the Intervals, and finally an intervalmatch that creates a third
table that bridges the two first tables.
IntervalMatch (Date)
IntervalMatch.qvw
Load
distinct
ToDate resident Intervals;
Copyright
2013
AccentureFromDate,
All Rights Reserved.
62
Copyright 2013 Accenture All Rights Reserved.
FUNCTIONS IN QLIKVIEW
> CROSSTABLE()
QlikView is also able to convert crosstables (a table where there is a column for
each dimension in a range) to traditional tables. For the file we are loading in this
example, we won't need this function, but it's important that you know about it
since this table structure is very common, particularly in budget spreadsheets.
An example of a crosstable is shown here
Departm
ent
Mont
h
Amou
nt
Jan
160
Feb
336
63
CrossTable.qvw
Agenda
BASIC OF QLIKVIEW
SCRIPTING---------------------------------------------- BUILDING YOUR DATA
MODEL----------------------------------------------- TEA BREAK /
EMAILS----------------------------------------------------------- ALL ABOUT
QVDS--------------------------------------------------------------- THE LOAD
STATEMENT-------------------------------------------------------- CONCATENATION &
JOINS----------------------------------------------------- Functions for manipulating string
Functions
LUNCH BREAK
/
for mathematical
calculation
EMAILS------------------------------------------------------- Question & Answer
FUNCTIONS IN
QLIKVIEW----------------------------------------------------- STRING MANIPULATION AND MATHEMATICAL
Copyright 2013 Accenture All Rights Reserved.
FUNCATIONS-------Copyright
2013 Accenture All Rights Reserved.
09:00
AM
09:15
AM
09:15
AM
10:00
AM
10:00
AM
10:30
AM
10:30
AM
11:00
AM
11:00
AM
11:10
AM
11:10
AM
12:30
PM
12:30
AM
01:30
PM
01:30
PM
03:00
64
PM
03:00
PM
03:30
PM
67
68
69
String Manipulation.qvw
Explanatio
n
Example
Result
Add
2+2
Subtract
10 5
Multiply
5*5
25
Divide
25 / 5
Function
Explanation
Example
Result
Ceil()
Ceil(2.5)
Ceil(2.6, 0.25)
3
2.75
Floor()
Floor(2.5)
Floor(2.6, 0.25)
2
2.25
Round(3.14)
Round(3.16,700.1)
Round(3.14, 0.1)
3
3.20
3.10
Round()
Explanation
Example
Result
Year()
Year(Date)
2012
Month()
Month(Date)
Week()
Week(Date)
21
Day()
Day(Date)
22
Weekday(Date)
Hour()
Hour(Date)
10
Minute()
Minute(Date)
15
Today()
Today()
2013-1115
MakeDat
e()
72
Agenda
BASIC OF QLIKVIEW
SCRIPTING---------------------------------------------- BUILDING YOUR DATA
MODEL----------------------------------------------- TEA BREAK /
EMAILS----------------------------------------------------------- ALL ABOUT
QVDS--------------------------------------------------------------- THE LOAD
STATEMENT-------------------------------------------------------- CONCATENATION &
JOINS----------------------------------------------------- LUNCH BREAK /
EMAILS------------------------------------------------------- PICK()
INABOVE()
FUNCTIONS
EXISTS()
QLIKVIEW----------------------------------------------------- STRING MANIPULATION AND MATHEMATICAL
Copyright 2013 Accenture All Rights Reserved.
FUNCATIONS-------Copyright
2013 Accenture All Rights Reserved.
09:00
AM
09:15
AM
09:15
AM
10:00
AM
10:00
AM
10:30
AM
10:30
AM
11:00
AM
11:00
AM
11:10
AM
11:10
AM
12:30
PM
12:30
AM
01:30
PM
01:30
PM
03:00
73
PM
03:00
PM
03:30
PM
Above.qvw
Copyright 2013 Accenture All Rights Reserved.
Copyright 2013 Accenture All Rights Reserved.
75
76
Exists.qvw
Agenda
BASIC OF QLIKVIEW
SCRIPTING---------------------------------------------- BUILDING YOUR DATA
MODEL----------------------------------------------- TEA BREAK /
EMAILS----------------------------------------------------------- ALL ABOUT
QVDS--------------------------------------------------------------- THE LOAD
STATEMENT-------------------------------------------------------- CONCATENATION &
JOINS----------------------------------------------------- LUNCH BREAK /
EMAILS------------------------------------------------------- FUNCTIONS IN
IFTHENELSEEND IF
QLIKVIEW---------------------------------------------------- LOOPS
- SELECT CASE
STRING MANIPULATION AND MATHEMATICAL
Copyright 2013 Accenture All Rights Reserved.
FUNCATIONS-------Copyright
2013 Accenture All Rights Reserved.
09:00
AM
09:15
AM
09:15
AM
10:00
AM
10:00
AM
10:30
AM
10:30
AM
11:00
AM
11:00
AM
11:10
AM
11:10
AM
12:30
PM
12:30
AM
01:30
PM
01:30
PM
03:00
77
PM
03:00
PM
03:30
PM
78
Looping.qvw
79
80 SWITCH
Case.qvw
Generic LOAD
Another table structure we can come across when loading data into QlikView is
what we call a generic table.
A generic table is commonly used to store attribute values for different objects.
These attributes are not necessarily shared across all objects contained in the
table, and that's one of the reasons why a traditional columnar structure is not
used for these tables.
Objec
t
Ball
Ball
Ball
Coin
Coin
Coin
Attribut
e
Value
Color
Yellow
Weight 120 g
Diameter 8 cm
Color
Gold
Value
$100
Diameter 2.5 cm
81Generic
Load.qvw
Agenda
BASIC OF QLIKVIEW
SCRIPTING---------------------------------------------- BUILDING YOUR DATA
MODEL----------------------------------------------- TEA BREAK /
EMAILS----------------------------------------------------------- ALL ABOUT
QVDS--------------------------------------------------------------- THE LOAD
STATEMENT-------------------------------------------------------- CONCATENATION &
JOINS----------------------------------------------------- LUNCH BREAK /
EMAILS------------------------------------------------------- FUNCTIONS IN
QLIKVIEW----------------------------------------------------- STRING MANIPULATION AND MATHEMATICAL
Copyright 2013 Accenture All Rights Reserved.
FUNCATIONS-------Copyright
2013 Accenture All Rights Reserved.
09:00
AM
09:15
AM
09:15
AM
10:00
AM
10:00
AM
10:30
AM
10:30
AM
11:00
AM
11:00
AM
11:10
AM
11:10
AM
12:30
PM
12:30
AM
01:30
PM
01:30
PM
03:00
82
PM
03:00
PM
03:30
PM
Qualify_UnQualify
.qvw
83
84 Rename
Fields.qvw
85
Question ???
Any
Questi
ons?
Copyright 2013 Accenture All Rights Reserved.
Copyright 2013 Accenture All Rights Reserved.
86
References
1. WWW.Qlikview.com
2. Qlikview 11 Developer book (PDF)
3. Qlikview 11 Reference Manual (PDF)
87
Thank
You
Copyright 2013 Accenture All Rights Reserved.
Copyright 2013 Accenture All Rights Reserved.
88