Skip to content

Instantly share code, notes, and snippets.

View ralfbecher's full-sized avatar

Ralf Becher ralfbecher

View GitHub Profile
@ralfbecher
ralfbecher / QlikView_Unnest_Field_Data_While.qvs
Created September 10, 2013 12:10
Unnest dynamic amount of data stored in field value using LOAD While:
// unnest data of field value:
Input:
LOAD * INLINE [
ACCOUNT, SUPPLIES
001, "Apples,Bananas,Tomatos"
002, "Bread,Butter,Cheese"
003, "Pretzel,Wuerstl"
];
Result:
@ralfbecher
ralfbecher / QlikView_List_of_Values_Variable.qvs
Created September 11, 2013 20:45
Create a list of values variable for the usage in a SQL Where IN-Clause.
Companies:
LOAD * INLINE [
Company
CompanyA
CompanyB
CompanyC
];
List:
LOAD
@ralfbecher
ralfbecher / mashupEnigma.js
Created December 29, 2017 15:15
Qlik Sense Mashup bind Enigma before openApp() is called
//
// Bind Enigma before openApp() is called
//
var prefix = window.location.pathname.substr(0, window.location.pathname.toLowerCase().lastIndexOf("/extensions") + 1);
var config = {
host: window.location.hostname,
prefix: prefix,
port: window.location.port,
isSecure: window.location.protocol === "https:"
};
@ralfbecher
ralfbecher / getObjectId.ts
Created December 28, 2017 22:52
Qlik Sense Extension get right Object Id in all Situations (vanilla, master item, story)
function getObjectId(scope: any): Promise<string> {
return new Promise((resolve, reject) => {
try {
let objectId: string = "";
if (scope.layout.sourceObjectId) {
// story
objectId = scope.layout.sourceObjectId;
scope.component.model.app.getObject(objectId)
.then( ( obj: EngineAPI.IGenericObject ) => {
obj.getProperties()
@ralfbecher
ralfbecher / Qlik_master_Calendar_DE.qvs
Created November 16, 2017 08:32
Qlik Master Calendar Script
Kalender:
Load
TempDate AS [Issue Datum],
Year(TempDate) As Jahr,
Month(TempDate) As Monat,
monthname(TempDate) as [Monat Jahr],
Day(TempDate) As Tag,
'Q' & ceil(month(TempDate) / 3) AS Quartal,
'Q' & ceil(month(TempDate) / 3) & ' ' & Year(TempDate) AS [Quartal Jahr],
Dual('KW' & Week(weekstart(TempDate)), Week(weekstart(TempDate))) as Woche,
@ralfbecher
ralfbecher / Qlik_Jira_Time_Formattings.qvs
Created November 15, 2017 16:24
Qlik JIRA Time Formatting
// Format a time like in JIRA: 4w 3d 06:30
// means: 4 weeks + 3 days (1 day = 8 hrs) + 6 hrs + 30 mins
If(Floor(Sum(AllIssues_fields_aggregatetimeoriginalestimate)/28800)/5 >= 1,
Num(Floor(Floor(Sum(AllIssues_fields_aggregatetimeoriginalestimate)/28800)/5), '#0') & 'w ', '') &
Num(Frac(Sum(AllIssues_fields_aggregatetimeoriginalestimate)/28800/5) * 5, '#0') & 'd ' &
Interval(Frac(Sum(AllIssues_fields_aggregatetimeoriginalestimate)/28800)/3, 'hh:mm')
@ralfbecher
ralfbecher / QlikSenseClassicExtensionDebounceExample.js
Created May 9, 2017 21:53
A simple way to debounce in a paint() function of a classic (non-angular) QlikSense extension
define([
"jquery",
"qlik",
"underscore"
],
function ($, qlik, _) {
'use strict';
return {
initialProperties: {},
@ralfbecher
ralfbecher / KeepFields.qvs
Created May 1, 2017 20:40
Qlik Script Sub KeepFields to Drop mass fields
Sub KeepFields(Fields,TableName)
Let n = NoOfFields('$(TableName)');
Set d = #;
For i = 1 to $(n)
Let f = FieldName($(i), '$(TableName)');
If Index('$(Fields)', ',$(f),') = 0 then
If '$(d)' = '#' then
Let d = '$(f)';
Else
Let d = '$(d),$(f)';
@ralfbecher
ralfbecher / QlikView_WeekName_to_Date.qvs
Created September 2, 2013 10:34
Converts a given weekname (eg. 2013/36) to the starting date of the week. Opposite of QlikView WeekName() function.
// Convert weekname (eg. format YYYY/WW) to date:
=MakeWeekDate(subfield(field, '/', 1), subfield(field, '/', 2), 0)
@ralfbecher
ralfbecher / QlikView_Data_Sampling.qvs
Last active January 25, 2017 16:18
Load a random sampling data set for Data Profiling in QlikView.
// in this case we want to load a 10% sampling set of the data
data:
LOAD ….<your fields>…
FROM <your QVD file>
WHERE ceil(rand() * 100) <= 10; // or: rand() <= 0.1
// SAMPLE n LOAD is much faster but allocates the memory of the full data set during the LOAD
// Where rand() <= n allocates only the memory of the smaller result set which could be crucial with Big Data..