Skip to content

Instantly share code, notes, and snippets.

Avatar

Ralf Becher ralfbecher

View GitHub Profile
@ralfbecher
ralfbecher / mashupEnigmaRequire.js
Created Feb 6, 2018
Qlik Sense Mashup with Enigma.js - the official way
View mashupEnigmaRequire.js
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:"
};
require.config({
baseUrl: (config.isSecure ? "https://" : "http://") + config.host + (config.port ? ":" + config.port : "") + config.prefix + "resources"
});
@ralfbecher
ralfbecher / QlikView_Generic_Load_Example_Table_Consolidation.qvs
Last active Sep 17, 2019
Generic load example from QlikView Reference Manual with table consolidation.
View QlikView_Generic_Load_Example_Table_Consolidation.qvs
// generic load with one consolidated resulting table:
InputTable:
LOAD * INLINE [
object,attribute,value
ball,color,red
ball,diameter,10 cm
ball,weight,100 g
box,color,black
box,height,16 cm
box,length,20 cm
@ralfbecher
ralfbecher / dateFromQlikNumber.js
Last active Mar 30, 2019
JavaScript function to create a Date from QlikView or Qlik Sense numerical Date value
View dateFromQlikNumber.js
function dateFromQlikNumber(n) {
var d = new Date(Math.round((n - 25569) * 86400000));
// since date was created in UTC shift it to the local timezone
d.setTime(d.getTime() + d.getTimezoneOffset() * 60000);
return d;
}
@ralfbecher
ralfbecher / QlikView_Calculate_Benford_s_Law.qvs
Last active Aug 9, 2018
Calculate Benford's Law in QlikView
View QlikView_Calculate_Benford_s_Law.qvs
//QlikView Script, Load the distribution of first digits, according to Benford's law, as Data Island:
Benford:
LOAD FirstDigit, log10(FirstDigit+1) - log10(FirstDigit) as OccurancePct;
LOAD RecNo() as FirstDigit AutoGenerate(9);
//***********************************************************************************
//Chart
//Dynamic Dimension;
=ValueList(1,2,3,4,5,6,7,8,9)
@ralfbecher
ralfbecher / QlikView_color_code_temperature_Celsius.qvs
Created Aug 21, 2015
QlikView color code for temperature in Celsius
View QlikView_color_code_temperature_Celsius.qvs
// calculates hue for temperature from -30 to +30 °C:
hsl((30 + 240 * (30 - max({<Etage={EG}>} Temp)) / 60) / 255, 0.75, 0.9)
@ralfbecher
ralfbecher / QlikView_Unnest_Field_Data_While.qvs
Created Sep 10, 2013
Unnest dynamic amount of data stored in field value using LOAD While:
View QlikView_Unnest_Field_Data_While.qvs
// 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 Sep 11, 2013
Create a list of values variable for the usage in a SQL Where IN-Clause.
View QlikView_List_of_Values_Variable.qvs
Companies:
LOAD * INLINE [
Company
CompanyA
CompanyB
CompanyC
];
List:
LOAD
@ralfbecher
ralfbecher / mashupEnigma.js
Created Dec 29, 2017
Qlik Sense Mashup bind Enigma before openApp() is called
View mashupEnigma.js
//
// 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 Dec 28, 2017
Qlik Sense Extension get right Object Id in all Situations (vanilla, master item, story)
View getObjectId.ts
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 Nov 16, 2017
Qlik Master Calendar Script
View Qlik_master_Calendar_DE.qvs
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,
You can’t perform that action at this time.