You are on page 1of 7

Qlikview Tips

Contributed By Anbu Cheliyan
Version Number 1
Creation Date 060!"01#
Page 1 of 7
Table o$ Contents
1 %ortin& weekdays in di'erent order..................................................................................2
" (ind bank havin& hi&hest rate........................................................................................... 2
) %e*uen+e number &eneration similar to row,number-. over-. in s*l.........................4
# Top ! %alesman.................................................................................................................... 5
5 Cumulative sum in script.......................................................................................................... 5
Page 2 of 7
1 Sorting weekdays in diferent order
/$ you want to order data $rom 0ednesday throu&h Tuesday1 then
add the below $un+tion in %ort  23pression
4at+h-0eek(ield1 50ednesday51 5Thursday51 5(riday51 5%aturday51 5%unday51
54onday51 5Tuesday5.
4at+h $un+tion per$orms +ase sensitive +omparison and returns inte&er
value based on position o$ e3pression
/$ 0eek(ield650ednesday51 4at+h returns 1
/$ 0eek(ield65Thursday51 4at+h returns "
78
/$ 0eek(ield65Tuesday51 4at+h returns 9
2 Find bank having highest rate
/nitial:
LOAD ; /N</N2 =
Bank1 >ate
A1 089
B1 08?
C1 08!
D1 18"
21 181
@A
(inal:
Load
(irst%ortedValue-Bank1B>ate.1 (ieldValue-5Bank51(ieldinde3- 5>ate51
ma3->ate. .. >esident /nitialA
frstsortedvalue ([ distinct ] e!ression [" sort#weight [" n ]]$
>eturns the Crst value o$ e3pression sorted by +orrespondin& sortB
wei&ht when e3pression is iterated over a number o$ re+ords as
deCned by a &roup by +lause8 %ortBwei&ht should return a numeri+
value where the lowest value will render the +orrespondin& value o$
e3pression to be sorted Crst8 By pre+edin& the sortBvalue
e3pression with a minus si&n1 the $un+tion will return the last value
instead8
Page 3 of 7
(irst%ortedValue-Bank1B>ate. >eturns Bank havin& hi&hest >ate8
Ne&ative si&n denotes order by >ate in des+endin&
2*uivalent s*l
%ele+t Bank (rom -%ele+t Bank $rom Table Drder by >ate Des+.
0here rownum E "
Field%nde(feldna&e " value $
>eturns the position o$ the Celd value value $ound in the Celd
Celdname -by load order.8 /$ value +annot be $ound amon& the
Celd values1 0 is returned8 Celdname must be &iven as a strin&
value1 e8&8 the Celd name must be en+losed by sin&le *uotes8
Field'alue(feldna&e " n $
>eturns the Celd value $ound in position n o$ the Celd Celdname
-by load order.8 Celdname must be &iven as a strin& value1 e8&8
the Celd name must be en+losed by sin&le *uotes8 The Crst Celd
value is returned $or n618 /$ n is lar&er than the number o$ Celd
values1 NF<< is returned8
(irst / determine the row +ontainin& the hi&hest rate:

(ieldinde3- 5>ate51 ma3->ate. ..BBG row number #

To retrieve the value o$ Bank in the #th row:

(ieldvalue-5Bank51Celdinde3- 5>ate51 ma3->ate. ..
( Se)uence nu&ber generation si&ilar to row*nu&ber($
over($ in s)l
/nput
/D1<e&/D1Anode1Hnode
%114%B"1N"1N)
%114%B11N11N"
%114%B#1N#1N!
%114%B)1N)1N#
%"14%B"1N"1N)
%"14%B!1N)1N6
Page 4 of 7
Dutput:
sele+t /D1<e&/D1 row,number-. over-partition by /D order
by <e&/D. $rom Table
/D1Cktid1 %e*uen+e/D
%114%B111
%114%B"1"
%114%B)1)
%114%B#1#
%"14%B"11
%"14%B!1"
%our+e:
load ; inline =
/D1<e&/D1Anode1Hnode
%114%B"1N"1N)
%114%B11N11N"
%114%B#1N#1N!
%114%B)1N)1N#
%"14%B"1N"1N)
%"14%B!1N)1N6
@A

table:
load
AutoNumber-<e&/D1 /D. as %e*uen+e1
;
>esident sour+e
order by /D1 <e&/DA

D>DI Table sour+eA
autonumber-e3pression= 1 Auto/D@.
>eturns a uni*ue inte&er value $or ea+h distin+t evaluated value
o$ e3pression en+ountered durin& the s+ript e3e+ution8 This
$un+tion +an be used e8&8 $or +reatin& a +ompa+t memory
representation o$ a +omple3 key8
/n order to +reate multiple +ounter instan+es i$ the autonumber
$un+tion is used on di'erent keys within the s+ript1 an optional
parameter Auto/D +an be used $or namin& ea+h +ounter8
Page 5 of 7
4 +o! , Sales&an
18 Fsin& +al+ulated dimension
6/(-a&&r-rank-sum-%ales..1%alesman.E6!1%alesman.
Cal+ulate >ank-%um-%ales.. a&ainst dimension %alesman
"8 Iresentation BBG 4a3 Number
%et 4a3 Number to ! in Iresentation tab and sort %ales on
des+endin&
)8 Dimension limits
%et %how only (irst ! in Dimension limits tab and sort %ales on
des+endin& in %ort tab
#8 %et analysis
6sum-JE%alesman 6 J56rank-sum-%ales.11.E6!5KGK %ales.
5 Cumulative sum in script
Cumulative,sum:
Load ; /nline
=
/D1a
11 1
"1
)1 1
#1 1
!1
@A
NoCon+atenate
table:
load
/D1
>an&e%um-a1 Ieek-5Cum%um5.. A% Cum%um
>esident Cumulative,sum
order by /D1 aA
Dro! table Cumulative,sumA
>an&e%um-e3pr1 = 1 e3pr"1 888 e3prN @.
>eturns the sum o$ a ran&e o$ 1 to N ar&uments8 >an&esum will
treat all nonBnumeri+ values and nulls as 08
Page 6 of 7
Ieek-5Cum%um5.
returns the value o$ +umulative sum in the previous re+ord read
- e*uivalent to previous-Cum%um. .8
6 Qlikview functions
- IreC3 Leros to a number and make $our di&it number
>i&ht->epeat-5051#. M 51"51#.
- Case statement e*uivalent in Qlikview
CA%2
0N2N I%0N%2 6 001 TN2N T>/4-I%A>2A. OO
T>/4-I%HDN2. OO <2(T-T>/4-I%A/%<11.. OO T>/4-I%BAP.
0N2N I%0N%2 6 00) TN2N T>/4-I%A/%<. OO T>/4-I%<2V<.
OO T>/4-I%ID%N.
0N2N I%0N%2 6 0)1 TN2N T>/4-I%A/%<. OO T>/4-I%<2V<.
OO T>/4-I%ID%N.
2ND
Ii+k-4at+h-I%0N%21001100)10)1.
1 T>/4-I%A>2A. M T>/4-I%HDN2. M <2(T-T>/4-I%A/%<11.. M
T>/4-I%BAP.
1 T>/4-I%A/%<. M T>/4-I%<2V<. M T>/4-I%ID%N.
1 T>/4-I%A/%<. M T>/4-I%<2V<. M T>/4-I%ID%N.
.
-ith else e!ression
Ii+k-4at+h-I%0N%21001100)10)1../
1 else,e3pression
1 T>/4-I%A>2A. M T>/4-I%HDN2. M <2(T-T>/4-I%A/%<11.. M
T>/4-I%BAP.
1 T>/4-I%A/%<. M T>/4-I%<2V<. M T>/4-I%ID%N.
1 T>/4-I%A/%<. M T>/4-I%<2V<. M T>/4-I%ID%N.
.
Page 7 of 7