Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
My task is to create a Qlik Sense script to check whether a given set of EAN (European Article Numbers) numbers have the correct check digit.
If the given EAN Number has more or less than 13 digits is to be considered invalid.
The check digit is calculated based on the following set of rules.
1. Sum all the digits in even positions and multiply by 3.
2. Add all the digits in odd positions (except for the last one, which is the check digit) to the number you’ve got in the first step.
3. Divide that number, received in the second step, by 10 and take the remainder.
4. If the remainder is not 0, subtract it from 10.
EAN Number List:
123456789012
1234567890123
9999999999999
9999999999998
4045012019462
4045012020147
4045012001375
An Example of how it's done:
the check digit calculation for EAN Number 4045012020147:
The digits in even positions are: 0, 5, 1, 0, 0, 4, their sum is 10, multiplied by 3 it is 30;
The digits in odd positions (except the last one) are: 4, 4, 0, 2, 2, 1, their sum is 13, added to the number above it is 43;
Dividing 43 by 10 gives us 3 as a remainder;
It is not zero, so subtracting it from 10 to get the check digit: 7.
The check digit is "7".
Could anyone please guide me in how to achieve my goal.
Hope this helps.
Hope this helps.
Hi kaushiknsolanki,
Thank you very much for your help. It has worked to 100% and i have learned something new.
Thank you! 🙂