Skip to content

Instantly share code, notes, and snippets.

Avatar

Ralf Becher ralfbecher

View GitHub Profile
@ralfbecher
ralfbecher / QlikView_Haversine_formula.qvs
Created Dec 16, 2015
QlikView Haversine formula calculation
View QlikView_Haversine_formula.qvs
// calculation of distance of two geo references (lat/lon):
= 12742 * atan2(sqrt(sqr(sin(((lat2-lat1)*PI()/180)/2))
+ (cos(lat1*PI()/180) * cos(lat2*PI()/180))
* pow(sin(((lon2-lon1)*PI()/180)/2),2)),
sqrt(1 - (sqr(sin(((lat2-lat1)*PI()/180)/2))
+ (cos(lat1*PI()/180) * cos(lat2*PI()/180))
* pow(sin(((lon2-lon1)*PI()/180)/2),2))))
@ralfbecher
ralfbecher / QlikView_Generic_Load_Example_Table_Consolidation.qvs
Last active Mar 6, 2021
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 / getSnowflakeQueryID.go
Last active Feb 6, 2021
Golang get Snowflake QueryID out of *sql.Rows
View getSnowflakeQueryID.go
import (
"context"
"database/sql"
"database/sql/driver"
"errors"
"reflect"
// ...
sf "github.com/snowflakedb/gosnowflake"
)
@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 / 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:"
};