-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqlikview-tpl.xml
143 lines (143 loc) · 6.51 KB
/
qlikview-tpl.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?xml version="1.0"?>
<Templates encode="utf8escenc"><Template Name="Binary Load">BINARY [+QVW Path+];
</Template><Template Name="Calendar Script - Basic">// Calendar Script - Basic - Start
LET vMinDate = num(makedate(2013,01,01));
LET vMaxDate = num(makedate(2013,12,31));

TempCalendar:
LOAD
date($(vMinDate) + IterNo() - 1) AS TempDate
AUTOGENERATE 1 WHILE $(vMinDate) + IterNo() -1 <= $(vMaxDate);

LET vMinDate = null();
LET vMaxDate = null();

MasterCalendar:
LOAD
TempDate AS $(vDateField),
year(TempDate) AS Year,
dual('Quarter ' & ceil(month(TempDate)/3), ceil(month(TempDate)/3)) AS Quarter,
month(TempDate) AS Month,
week(TempDate) AS Week,
day(TempDate) AS Day,
WeekDay(TempDate) AS WeekDay,
dual('Q' & ceil(month(TempDate)/3) & '-' & year(TempDate), quarterstart(TempDate)) AS QuarterYear,
date(monthstart(TempDate), 'MMM-YYYY') AS MonthYear,
dual(week(TempDate) & '-' & weekyear(TempDate), weekstart(TempDate)) AS WeekYear
RESIDENT TempCalendar;

DROP TABLE TempCalendar; 
// Calendar Script - Basic - End
</Template><Template Name="Calendar Script - Basic - From Field">// Calendar Script - Basic - From Field - Start
SET vDateField = [+Date Field+];
SET vDateFieldTable = [+Date Field Table+];

Temp:
LOAD
min($(vDateField)) AS minDate,
max($(vDateField)) AS maxDate
RESIDENT $(vDateFieldTable);

LET vMinDate = num(peek('minDate', 0, 'Temp'));
LET vMaxDate = num(peek('maxDate', 0, 'Temp'));

DROP TABLE Temp;

TempCalendar:
LOAD
date($(vMinDate) + IterNo() - 1) AS TempDate
AUTOGENERATE 1 WHILE $(vMinDate) + IterNo() -1 <= $(vMaxDate);

LET vMinDate = null();
LET vMaxDate = null();

MasterCalendar:
LOAD
TempDate AS $(vDateField),
year(TempDate) AS Year,
dual('Quarter ' & ceil(month(TempDate)/3), ceil(month(TempDate)/3)) AS Quarter,
month(TempDate) AS Month,
week(TempDate) AS Week,
day(TempDate) AS Day,
WeekDay(TempDate) AS WeekDay,
dual('Q' & ceil(month(TempDate)/3) & '-' & year(TempDate), quarterstart(TempDate)) AS QuarterYear,
date(monthstart(TempDate), 'MMM-YYYY') AS MonthYear,
dual(week(TempDate) & '-' & weekyear(TempDate), weekstart(TempDate)) AS WeekYear
RESIDENT TempCalendar;

DROP TABLE TempCalendar; 

LET vDateField = null();
LET vDateFieldTable = null();
// Calendar Script - Basic - From Field - End
</Template><Template Name="Environment Variables">SET ThousandSep=',';
SET DecimalSep='.';
SET MoneyThousandSep=',';
SET MoneyDecimalSep='.';
SET MoneyFormat='£#,##0.00;-£#,##0.00';
SET TimeFormat='hh:mm:ss';
SET DateFormat='DD/MM/YYYY';
SET TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';
SET MonthNames='J;F;M;A;M;J;J;A;S;O;N;D';
SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';
</Template><Template Name="Include Statement">$(Include=[+Script File Path+]);
</Template><Template Name="Let Statement">LET [+Variable Name+] = [+Variable Expression+];
</Template><Template Name="Script Header Comment">///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// [+SCRIPT TITLE+]
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// [+Script description/purpose+] 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// COPYRIGHT/LICENSE:
// Copyright [DATE_DMY]
// [+License Details+]
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CHANGE LOG:
// [DATE_DMY] - [+J. Bloggs+] - Initial creation.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// KNOWN ISSUES / PLANNED IMPROVEMENTS:
// [DATE_DMY] - [+J. Bloggs+] - [+Details of issue/improvement.+] 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// NAMING CONVENTIONS:
// The following naming convensions are used throughout this script:
// Subroutines - Given logical names in capitalised case without spaces between words (eg. "SalesData")
// Variables - Start with a lowercase "v" and should follow the pattern "vStartDate"
// Fields - Given logical, user friendly names in capitalised case with spaces between words (eg. "Sale Date")
// Tables - Given logical names in capitalised case without spaces between words (eg. "SalesData")
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
</Template><Template Name="Script Section Comment">///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// [+SCRIPT SECTION TITLE+]
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
</Template><Template Name="Set Statement">SET [+Variable Name+] = [+Variable Value+];
</Template><Template Name="Test Script">// Test Script - Start
Characters:
Load Chr(RecNo()+Ord('A')-1) as Alpha, RecNo() as Num autogenerate 26;

ASCII:
Load 
if(RecNo()>=65 and RecNo()<=90,RecNo()-64) as Num,
Chr(RecNo()) as AsciiAlpha, 
RecNo() as AsciiNum
autogenerate 255
Where (RecNo()>=32 and RecNo()<=126) or RecNo()>=160 ;

Transactions:
Load
TransLineID, 
TransID,
mod(TransID,26)+1 as Num,
Pick(Ceil(3*Rand1),'A','B','C') as Dim1,
Pick(Ceil(6*Rand1),'a','b','c','d','e','f') as Dim2,
Pick(Ceil(3*Rand()),'X','Y','Z') as Dim3,
Round(1000*Rand()*Rand()*Rand1) as Expression1,
Round( 10*Rand()*Rand()*Rand1) as Expression2,
Round(Rand()*Rand1,0.00001) as Expression3;
Load 
Rand() as Rand1,
IterNo() as TransLineID,
RecNo() as TransID
Autogenerate 1000
While Rand()<=0.5 or IterNo()=1;

Comment Field Dim1 With "This is a field comment"; 
// Test Script - End
</Template></Templates>