Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, i'm trying to take load off of Google Sheets because I have it verifying if my customer's info is correct, which slows everything down. What I need is for Qlikview to do the same job that Sheets is doing with the script i'm loading every time a customer registers on my site.
This is the function I've added:
function RUT() {
//https://stackoverflow.com/questions/1527803/generating-random-whole-numbers-in-javascript-in-a-specific-range
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var number = getRandomInt(1000000, 100000000);
var digit = RUTDIGIT(number);
return number.toString() + "-" + digit;
}
function RUTDIGIT(number) {
//https://stackoverflow.com/questions/4856717/javascript-equivalent-of-pythons-zip-function/7260572
function zip() {
var args = [].slice.call(arguments);
var shortest = args.length==0 ? [] : args.reduce(function(a,b){
return a.length<b.length ? a : b
});
return shortest.map(function(_,i){
return args.map(function(array){return array[i]})
});
}
var digits = number.toString().split('').map(Number).reverse();
var series = Array(digits.length + 1).join().split('').map(function(x, i) { return (i % 6) + 2; }); //[2,3,4,5,6,7,2,3...]
var digit = (11 - (zip(digits, series).map(function(pair) { return pair[0] * pair[1]; }).reduce(function(a,b) { return a + b; }, 0) % 11)).toString();
if(digit === '11') digit = '0';
if(digit === '10') digit = 'K';
return digit;
}
//Spanish alias of RUTDIGIT
function DIGITORUT(number) {
return RUTDIGIT(number);
}
function VERIFYRUT(rut, digit) {
return RUTDIGIT(rut) === digit.toString();
}
//Spanish alias of VERIFYRUT
function VERIFICARUT(rut, digit) {
return VERIFYRUT(rut, digit);
}
Then, when Sheets sees a new lead, i make a Cell run this formula:
=VERIFYRUT((LEFT("XXXXXXXXXX"; LEN("XXXXXXXXXX")-1));RIGHT("XXXXXXXXXX";1))
What this does, is check that the numbers follow a certain formula, and if it's correct, it shows TRUE. If false "FALSE".
Can anybody help me out translating this google script to a Qlik Sense script/function?
I need to understand exactly what percentage of "Social Security Numbers" are fake, and how many are real.
Thanks!!!
OK so this solution depends on your environment and toys you have access to.
My recommendation is to implement a RegEx check of your numbers based on this article.
https://www.geeksforgeeks.org/how-to-validate-ssn-social-security-number-using-regular-expression/
RegEx is however not supported natively in Qlik sense you will need install and use Qlik Web Connectors