Skip to content

Instantly share code, notes, and snippets.

@hurrifan1
Created April 30, 2021 17:34
Show Gist options
  • Save hurrifan1/397d42e1a37612ec96014f6583da2af7 to your computer and use it in GitHub Desktop.
Save hurrifan1/397d42e1a37612ec96014f6583da2af7 to your computer and use it in GitHub Desktop.
Master Qlik Script Template
/* Master script template! */
// ===============================================
// MAPPING
// ===============================================
[mapping]:
Mapping LOAD * Inline [
old, new
];
// ===============================================
// SUB
// ===============================================
SUB Load
[]:
LOAD
1
AutoGenerate 1;
END SUB
SUB Store
Store [] into 'lib://Space:DataFiles/file.qvd'(QVD);
END SUB
SUB Load_QVD
[]: LOAD * FROM 'lib://Space:DataFiles/file.qvd'(QVD);
END SUB
// ===============================================
// LOAD
// ===============================================
/* Table */
Call Load
Call Store
// Call Load_QVD
// ===============================================
// ETL
// ===============================================
Qualify *;
// Unqualify [];
[t]:
NoConcatenate LOAD
[]
, []
, []
Resident [];
Unqualify *;
Drop Table [];
Rename Table [t] to [];
// ===============================================
// CALENDAR
// ===============================================
cal:
DECLARE FIELD DEFINITION TAGGED '$date'
Parameters
first_day_of_week = 6
Fields
Year($1) As Year Tagged ('$numeric'),
Month($1) as Month Tagged ('$numeric'),
MonthName($1) as MonthYear Tagged ('$numeric'),
Date($1) as Date Tagged ('$date'),
Dual( Date(WeekStart($1, 0, first_day_of_week), 'M/D/YY') & ' - ' & Date(WeekEnd($1, 0, first_day_of_week), 'M/D/YY'), WeekStart($1, 0, first_day_of_week)) as Week Tagged ('$numeric'),
Weekday($1) as Weekday Tagged ('$numeric')
;
DERIVE FIELDS FROM FIELDS [Date] USING cal;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment