This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Load | |
floor(((Date2 - Date1)+1)/7)*6 + mod((Date2 - Date1)+1,7) | |
+ if(Weekday(Date1) + mod((Date2 - Date1)+1,7) < 7, 0, -1) as Workingdays_6 | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOAD | |
if(age<16, 'Under 16', | |
if(age>65, 'Over 65', | |
text(16+(Div(age-16,10)*10)) & ' - ' & text(25+(Div(age-16,10)*10)))) as age_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Solution 1: | |
Timestamp = ConvertToLocalTime(Date(MakeDate(1970, 1, 1) + (<timestamp_field> / 86400)), '<time_zone>') | |
// Solution 2: | |
Timestamp = ConvertToLocalTime(Date(25569 + (<timestamp_field> / 86400)), '<time_zone>') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load header row | |
Header: | |
FIRST 1 LOAD @1:n as First_Line | |
FROM flatfile.csv | |
(fix, codepage is 1252); | |
// load list of fields from source for renaming, replace square brackets with paranthesis (or something else), | |
// delimiter is '|' | |
Map_Fields: | |
MAPPING LOAD '@' & RowNo() as Field1, Replace(Replace(SubField(First_Line, '|'), '[', '('), ']', ')') as Field2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In this case we want to load a 10% sampling set of the data | |
// The QlikView way: | |
data: | |
Sample(0.1) LOAD <your fields> | |
FROM <your source file> | |
// My way, using random function: | |
data: | |
LOAD <your fields> | |
FROM <your source file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LET t1 = (num(timestamp#('2013-01-11 18:00:00', 'yyyy-mm-dd hh:mm:ss')) - 25569) * 86400; | |
LET t2 = (num(Now(1) - 25569) * 86400; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// expression for count($Field), no leading '=': | |
$(=concat(TOTAL 'if($Field=' & chr(39) & $Field & chr(39) & ',count([' & $Field & '])', ',') & concat(TOTAL right($Field&')',1))) | |
// expression for count(DISTINCT $Field): | |
=FieldValueCount($Field) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load header row | |
Header: | |
FIRST 1 LOAD @1:n as First_Line | |
FROM flatfile.csv | |
(fix, codepage is 1252); | |
// load list of fields for renaming, replace square brackets with paranthesis | |
Map_Fields: | |
MAPPING LOAD '@' & RowNo() as Field1, Replace(Replace(SubField(First_Line, '|'), '[', '('), ']', ')') as Field2 | |
Resident Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* source data (delimiter=tab), in file D:\header.xlsx: | |
Header 1 part a Header 2 part a Header 3 part a Header 4 part a Header 5 part a | |
Header 1 part b Header 2 part b Header 3 part b Header 4 part b Header 5 part b | |
Data Data Data Data Data | |
Data Data Data Data Data | |
Data Data Data Data Data | |
Data Data Data Data Data | |
resulting table (delimiter=tab): | |
Header 1 part a Header 1 part b Header 2 part a Header 2 part b Header 3 part a Header 3 part b Header 4 part a Header 4 part b Header 5 part a Header 5 part b |