Skip to content

Instantly share code, notes, and snippets.

View ralfbecher's full-sized avatar

Ralf Becher ralfbecher

View GitHub Profile
@ralfbecher
ralfbecher / Create_Persian_calender_with_Oracle.pls
Created June 10, 2014 12:23
Create a Persian calender with Oracle PL/SQL, in this case it creates a table of all dates from 30.12.1899 to 31.12.2099 for the use in QlikView
CREATE TABLE "OCEAN"."T_DATE_PERSIAN"
(
"QV_DATE_NUM" NUMBER(6,0),
"GREGORIAN_DATE" DATE,
"PERSIAN_DATE" VARCHAR2(10 CHAR)
)
;
create or replace
PROCEDURE INSERT_T_DATE_PERSIAN IS
ʕ◔ϖ◔ʔ
U+0295, U+25D4, U+03D6, U+25D4, U+0294
@ralfbecher
ralfbecher / Qlik_Nice_Number_Format.qvs
Created December 14, 2016 14:17
Qlik Nice Number Format
//---------------------------------------------- Nice Numberformat simplified ---------------------------------------------
// does work with count in KPI object (have seen several versions from Qlik which haven't worked)
Set vF_NiceNumberSimple =
If(Fabs($1) > 1e9, Num($1/1e9+1e-13, '#$(ThousandSep)##0$(DecimalSep)00')
,If(Fabs($1) > 1e8, Num($1/1e6+1e-13, '##0$(DecimalSep)0')
,If(Fabs($1) > 1e6, Num($1/1e6+1e-13, '##0$(DecimalSep)00')
,If(Fabs($1) > 1e5, Num($1/1e3+1e-13,'##0$(DecimalSep)0')
,If(Fabs($1) > 1e3, Num($1/1e3+1e-13, '##0$(DecimalSep)00')
, $1,
))))) &
@ralfbecher
ralfbecher / QlikView_Haversine_formula.qvs
Created December 16, 2015 20:11
QlikView Haversine formula calculation
// 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 March 6, 2021 13:33
Generic load example from QlikView Reference Manual with table consolidation.
// 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 February 6, 2021 09:44
Golang get Snowflake QueryID out of *sql.Rows
import (
"context"
"database/sql"
"database/sql/driver"
"errors"
"reflect"
// ...
sf "github.com/snowflakedb/gosnowflake"
)
@ralfbecher
ralfbecher / mashupEnigmaRequire.js
Created February 6, 2018 16:07
Qlik Sense Mashup with Enigma.js - the official way
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 March 30, 2019 17:24
JavaScript function to create a Date from QlikView or Qlik Sense numerical Date value
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 August 9, 2018 18:45
Calculate Benford's Law in QlikView
//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 August 21, 2015 22:03
QlikView color code for temperature in Celsius
// calculates hue for temperature from -30 to +30 °C:
hsl((30 + 240 * (30 - max({<Etage={EG}>} Temp)) / 60) / 255, 0.75, 0.9)