Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 7897 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Given a number... like 86 for example, I need a calculation field to work out what needs to be added to that number to make it divisible by 10. In the case of 86 it would be 4.

I tried this...

Truncate (TheNumber, -1) + 10 - TheNumber

But that doesn't work if the number is already divisible by 10 (because it returns 10 when I want 0)

Do I have to add in an if statement to check for this or am I missing something simple?

Posted

OOps...

MOD(10 - MOD(num; 10); 10) for sure...

The bracket was a rest of

(MOD(10-MOD(num; 10); 10) + num) which I had used to pull 86 to 90... smirk.gif

which I first thought was what Jason was looking for.

Posted

Thank you all... my UPC bar code font is now fully functional and I'm ready to take over the world!!! Muhahaha!!!

Posted

Hi Ugo,

Your are the champ,

No need mucking up the waters with this:

Abs (Mod(YourNumber,10))

As it returned the same as:

Mod(Number, 10)

Lee

wink.gif

Posted

Its final. Ugo takes all the honors here.

I thought I was being clever with the little simple "Right" calculation. Oh No, what if the number is already divisible by 10. So, I thought I got clever with my abs post. Oh No, what about fractions.

Thats it, before I try to be too smart next time I am going to think the whole thing through before I post! But first I am thinking of a new "vanity" title for Ugo.

Pete

Posted

Jason and all here...

We now know that Abs is not working,

that MOD(10 - MOD(num, 10), 10) returns 4 for 86 if we want to add up

and

that MOD(10 + MOD(num, 10), 10) returns 4 for 84 if we want to substract.

Now, what would be the function to determine if it is 85,01 to round to 90 and if it is 84,99 to round to 80 ?

I've tried it at first and didn't find anything.

Any clue here ?

Posted

Hi Pete

[color:"blue"]And if the number is -157

Both returned 7, the opsit of coure of thecorrect answer of 3.

Lee confused.gif

Posted

Well,

just forgot about Round to round... blush.gif

So Round(YourNumber / 10, 0) * 10 - Your Number gives me the number to add or substract.

Cool. I'll use it for my pricing system....

Just forgot this silly titles wink.gif

Thanks for the whole thread.

Posted

Hi all

If ( Round(YourNumber/10, 0)*10 < YourNumber,

MOD(10 - MOD(num, 10), 10),

MOD(10 + MOD(num, 10), 10)

:? That right?

Ed

Posted

Thanks Eddy,

I'll try both method...

Just for information, I was planning to round my price list when the prices are > 200 euros.

So if a good is listed 204,90 euros, I'll round it to 199,99 with either "Eddy's calc -0,01" or "Pete's calc -0,01"

If it is listed 205,10, I'll round it to 209,99.

Thanks to both of you.

Well, I'd just change If to Case....

Posted

OK it was going to annoy me until I got it down so here's my final answer!

Case( (Round(Number/10, 0)*10) < Number , " - " & Mod(10 + Mod(Number, 10), 10) , (Round(Number/10, 0)*10) > Number , "+" & Mod(10 - Mod(Number, 10), 10))

Now I can sleep!

Ed.

Posted

Ugo, you can use the Round() function to round to a negative number of decimal places (ie, positions to the left of the decimal point). So, you can simply do it with:

Round(TheNumber,-1)

That will round it to the nearest 10.

Posted

And while I'm being obsessive, grin.gif

Here's another possiblility for Jason's calculation:

Mod(1000000000000000-TheNumber,10)

Okay, I'm going to quit now.

This topic is 7897 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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