Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Check Digit Calculation

Featured Replies

Given a number, say 2345678, I need to add up the ODD position digits and multiply the sum by 3. Then add up the EVEN position digits. Both sums are then added together. Finally, determine the value required to bring that sum up to the next multiplier of 10.

Example:

1. Calc of the odd position digits:(2+4+6+8)3 = 60

2. Calc of the even position digits: 3+5+7 = 15

3. Sum of both: 60+15 = 75

4. Value needed to bring 75 to the next multiplier of 10 (80) = 5

Any help from a REAL LEFT BRAINER is greatly appreciated!

Hi blindbo,

I came up with a real convoluted way, maybe others will make it smoother, but at least it will give you something to think about.

HTH

smile.gif

Choose.fp5.zip

  • Author

Lee,

I may have been unclear in my problem description.

I need to sum the digits that FALL into the odd, or even POSITIONS of the string.

To say it another way, the "odd" calc is the sum of the digits in the first, third, fifth, seventh...etc postion. Whereas the 'even' calc is the second, fourth, sixth...etc., position.

Any thoughts on that one? (I hope!)

You might need NumToText() to make the number into a string. Then use the Middle() function in combination with Position(). If the number is arbitrarily big, you might set up a field to use as a counter, set it to the Length() of the number, then increment it down to 0 in a Loop script. Each time through the Loop, you'd add a digit until the counter reaches 0.

I don't understand why you need to add the odd and even digits up separately if you're going to just add those two sums anyway. Why not just add up all the digits in the first place?

Finally, Mod(yourSum, 10) will give you what's left over when you divide by 10.

So, 10 - Mod(yourSum, 10) will give you the number you're after.

Hi blindbo,

This was actually easier than what I had come up with, man did I ever missread your first post.

I have made changes using Tom's Mod calculation which is much better than the one I used. Thanks Tom,

Anyway, I hope this is closer to what you need.

Lee

Choose.fp5.zip

  • Author

Tom: The first sum is multiplied by three, therefore it needed to be parsed out. Thanks for the reply as it was apparently a switch to another great light bulb in Lee's head!

Lee: YES! That works! Thank you so very, very much. This was beyond my current knowledge.

Anyone reading: This application is used to create a digit which is appended to the original number. This final number is used as a sequencing number for bank checks. When the check is scanned, it is validated by the check sum digit.

Oh yes, I see that 3 now. Caffeine has kicked in.

[color:"blue"]Anyone reading: This application is used to create a digit which is appended to the original number. This final number is used as a sequencing number for bank checks. When the check is scanned, it is validated by the check sum digit.

Now that I know what you want this for, you might want to check out this file by Ray J. Cologon aka CobaltSky around here smile.gif

Dynamic Check Digits - Modulus 10 and Modulus 11! http://www.nightwing.com.au/FileMaker/

It might be of some value to you.

HTH

Lee

Create a global number field, "Index" with 5 repetitions and put the numbers 1, 2, 3, 4, 5 into the respective repetitions.

Create a calculation field "ChecksumDigits" with 5 repetitions with the formula:

Middle(Extend(InputNo), Index*2-1, 1)*3+Middle(Extend(InputNo), Index*2, 1)

Finally create a calculation field "Checksum" with the formula:

Mod(Sum(ChecksumDigits),10)

See attached sample file

Checksum.fp5.zip

Hi Bob,

If you use the number 2589115 we get different numbers for the check sum. I get 5, and yours gives 3. Question is, who's is correct?

Lee

p.s., I tried to write you back channel but I see you don't receive Private Messages.

cool.gif

Actually, looking at it again, I think we are both wrong. Doing the calculation by hand, I get:

Odd digits: (2+8+1+5)*3=48

Even digits: 5+9+1=15

Total 15+48=63

Next higher multiple of 10=70

Checksum=70-63=7 (My formula had been doing a Mod 10 here and got 3 as a result)

I'm not sure how you came up with 5.

The formula for my Checksum field should be changed to:

Mod(1000-Sum(ChecksumDigits),10)

See the new attachement.

Sorry about my Private messages being switched off. I was getting way too many general Filemaker questions that should have been posted to the forums. So, I decided to shut it down.

Checksum.fp5.zip

Lee: I checked your formula and it gives the correct value of 7 not 5.

Hi Bob,

I had just used the one Tom posted, although my original formula had also gaven the same answer, which made me wonder what was wrong. Now, I need to examine your formula for my future need: wink.gif

10 - Mod(AddEvenAndOdd Copy, 10)

[color:"blue"]> I was getting way too many general Filemaker questions that should have been posted to the forums. So, I decided to shut it down.

I have had this problem too lately. Most of the time I just tell them to post to the forum and get more and probably better answers.

Lee

I know, it's called unstored calculations

Duh

blush.gif

Lee,

This formula

10 - Mod(AddEvenAndOdd Copy, 10)

can give the incorrect value of 10 instead of zero. It will give you the correct value of zero if you change it to:

Mod(1000-AddEvenAndOdd Copy, 10)

or to:

Mod(10-Mod(AddEvenAndOdd Copy, 10),10)

I assumed that Blindbo wants a single digit checksum. Hence, 0 rather than 10.

Hi Bob,

Thanks for the education, I really appreciate it.

I hope that Blindbo comes back and catches up on this.

Lee

BTW, If you have looked at some of my posts recently, you may have noticed that I have started using a bunch of calculations based on repeating fields which reference a global repeating field containing the values 1, 2, 3, 4... etc. I've found that you can solve some fairly complex problems with very simple calculations this way. The drawback is that the result must be unstored and therefore is not indexable.

Hi Bob,

[color:"blue"]> The drawback is that the result must be unstored and therefore is not indexable.

Easily overcome by a simple script and another field.

Thanks again,

Lee

  • Author

Bob, You are correct that I needed a single digit checksum, "0", instead of "10".

Lee's solution gave me the correct checksum, but did leave the 2-digit "10". I simply made a conditional statement to handle that (that much left-brained, I am!! LOL)

Thanks again, Lee!

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.