Skip to content

Instantly share code, notes, and snippets.

View ralfbecher's full-sized avatar

Ralf Becher ralfbecher

View GitHub Profile
@ralfbecher
ralfbecher / qlikNumberFromDate.js
Created May 16, 2016 15:47
JavaScript function to get QlikView or Qlik Sense numerical Date value from JavaScript Date
function qlikNumberFromDate(d) {
return d.getTime() / 86400000 + 25569;
}
(function() {
(function foo(node) {
if (node && node.$id) {
if (node.$$childHead) foo(node.$$childHead);
if (node.$$nextSibling) foo(node.$$nextSibling);
if (node.model && node.model.layout) node.model.layout.title = node.model.id;
}
})(qvangularGlobal.$rootScope);
$('*').css('-webkit-user-select', 'all');
pubsub.publish('/resize/end')
define( ["require"], function ( localRequire ) {
var path = localRequire.toUrl( "extensions/d3-vis-library/d3-vis-library.css" );
});
@ralfbecher
ralfbecher / QlikView_Scatter_Chart_determined_bubble_size.qvs
Last active February 12, 2016 21:11
QlikView Scatter Chart determined bubble size
// third expression:
dual( sum(Volume), sqrt( sum(Volume) ) )
// or
dual( sum(Betrag), pow( sum(Betrag), 0.7 ) )
@ralfbecher
ralfbecher / QlikView_Row-based_Transparent_Colors.qvs
Created February 12, 2016 18:49
QlikView Row-based Transparent Colors
// can be used in scatter chart to have persistend color for dimensions and nice opacity for overlapping bubbles:
=argb(180,
subfield(textbetween(color(RowNo()),'(',')'),',',1),
subfield(textbetween(color(RowNo()),'(',')'),',',2),
subfield(textbetween(color(RowNo()),'(',')'),',',3))
@ralfbecher
ralfbecher / Qlik_Expression_Baskets_ordered_by_Frequency.qvs
Last active February 5, 2016 10:28
Qlik Expression Baskets ordered by Frequency
// Baskets order by Frequency:
Concat(DISTINCT Product, ',', -Aggr(NODISTINCT Count(Product), Product))
@ralfbecher
ralfbecher / QlikView_Extension_determine_amount_of_Dimensions.js
Created January 4, 2016 18:30
QlikView Extension determine amount of Dimensions from first data row (if multiple)
// get amount of Dimensions
var nDimensions = this.Data.Rows[0].filter(function(col){return !(col.color == undefined);}).length;
@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_Expression_NewProductPerYear.qvs
Last active October 21, 2015 20:03
QlikView Chart Expression Counts New Products/Year
data:
LOAD * INLINE [
Year, Product
2010, P1
2011, P1
2012, P1
2010, P2
2011, P2
2011, P3
2012, P3
@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;
}