A library of useful Qlik subroutines that automate common tasks, support templating, and speed up the development of ETL pipelines
- Clone this repository to a location that is accessible to your Qlik Sense Enterprise server:
git clone https://github.com/viperior/qlik-snippets PATH_TO_UTILITY_SCRIPTS_FOLDER
- Create a new data connection in Qlik Management Console (QMC):
- Name: Qlik Utility Library
- Type: Folder
- Path: PATH_TO_UTILITY_SCRIPTS_FOLDER as defined in step 1
- Congratulations! You're ready to make use of the subroutines in this library.
cd PATH_TO_UTILITY_SCRIPTS_FOLDER
git pull
This subroutine retrieves the maximum value from a field when given a field name and table name.
[Example]:
Load
RowNo() AS [Row Number]
Autogenerate(100)
;
Let vTableName = 'Example';
Let vFieldName = 'Row Number';
Let vIncludePath = 'lib://Qlik Utility Library/GetMaxValue.qvs';
$(Must_Include=$(vIncludePath));
Call GetMaxValue(vMaxValue, vTableName, vFieldName);
Let vMessage = 'Max($(vFieldName)) = $(vMaxValue)';
Trace $(vMessage);
// Output: "Max(Row Number) = 100"
This subroutine performs automated analysis of a table's field values.
-
Copy the following code to the end of your Qlik script:
Let vIncludePath = 'lib://Qlik Utility Library/ProfileTableFieldValues.qvs'; $(Must_Include=$(vIncludePath)); Call ProfileTableFieldValues('Source Table Name', 'Output Table Name');
-
Reload the script and check the data model viewer. You should see your new table.