Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Check Digit


Recommended Posts

so i have data base that has ID's made out of 8 numbers, i need to make algorithm to take the 8 numbers and put the output Check Digit, can anyone plz tell me how to do that in steps??

Link to comment
Share on other sites

Can you explain how one would do it manually with a pencil and paper? Does the check digit equal the sum of the 8 numbers or something else? By "numbers" do you mean "digits", as in "the IDs are 8 digits long"?


So the check digit for 42387592 would be 40?


And the ID field is a single field that would contain a value such as 42387592 in it?



If so on all counts, define Check Digit as a calculation field, result type "number", defined as


Let ([

a= Middle (ID Field; 1; 1);

b=Middle (ID Field; 2; 1);

c=Middle (ID Field; 3; 1);

d=Middle (ID Field; 4; 1);

e=Middle (ID Field; 5; 1);

f=Middle (ID Field; 6; 1);

g=Middle (ID Field; 7; 1);

h=Middle (ID Field; 8; 1)








(there are recursive functions that would do this as well but this should definitely do it)

Link to comment
Share on other sites

The exact calculation will depend on what check digit algorithm you want. There are many algorithms for check digits and check sums, and they'll produce different results. If you don't have a particular algorithm in mind, the Damm algorithm is as good as it gets, and there's a FileMaker custom function that can handle the details for you (and another function to verify that a number has the correct final check digit). Just install the custom function in your file (using FileMaker Pro Advanced), and reference that in the calculation field AHunter3 described. Instead of the big Let function, you'd simply have:


CheckdigitDamm ( ID Field )


This said, it's weird to just want the check digit as a result. Normally, the useful output is the ID value including the check digit: ID Field & CheckdigitDamm ( ID Field ).


If you don't have FileMaker Pro Advanced (and therefor can't install custom functions), the Damm algorithm may be a lot of trouble to write in a basic calculation field without a custom function. AHunter3's example gives a good outline of the steps to build a calculation field, but I recommend against the exact calculation he used. It does not catch some of the most common errors that check digits are designed to catch, most notably, transposition errors (swapping the positions of any two digits). A more effective strategy is to multiply each digit in the sum by a different weight:


Let ( [

_a = Middle ( ID Field ; 1 ; 1 ) ;

_b = Middle ( ID Field ; 2 ; 1 ) ;

_c = Middle ( ID Field ; 3 ; 1 ) ;

_d = Middle ( ID Field ; 4 ; 1 ) ;

_e = Middle ( ID Field ; 5 ; 1 ) ;

_f = Middle ( ID Field ; 6 ; 1 ) ;

_g = Middle ( ID Field ; 7 ; 1 ) ;

_h = Middle ( ID Field ; 8 ; 1 ) ;

_sum = _a + 2 * _b + 3 * _c + 4 * _d + 5 * _e + 6 * _f + 7 * _g + 8 *_h

] ;

Mod ( _sum ; 10 )



Note the last step, Mod ( _sum ; 10 ), which reduces the result to a single digit if you want a single-digit checksum. If you want more than one digit (which will result in better performance catching errors), just use a bigger number, such as Mod ( _sum ; 100 ) for 2 digits. (If you want more than one digit worth of security and you can install custom functions, you might consider using a more powerful algorithm like a CRC and using the lowest digits from that as your checksum.)

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

Terms of Use