Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This formula rounds up to the nearest thousand. Please explain. 1

Status
Not open for further replies.

qu1ncy

Programmer
Jul 25, 2002
95
CA
Round({@SalaryX2}+499.9999999,-3)

The above formula was generously provided by a Tek-Tips member. When I was troubleshooting a report for my client, she asked me how it rounds up successfully and I was not able to explain it to her. Ashamed...!
Can someone please explain?

Much appreciated!
Q

 
Sicne you're adding less that 1/2 to the value while issuing a round of -3, it will always round up to that precision.

-k
 
The Round function isn't rounding up but is rounding to the nearest thousand but by adding 499 then the upper thousand will always be nearer than the lower thousand i.e.

x = 400

Round (x + 499, 3) = 1000

x = 999

Round (x + 499, 3) = 1000

The calculation I use for this purpose is

-int(-(({@SalaryX2})/1000))* 1000

I prefer to use this as you can replace 1000 with any number and the result will be rounded up to that number

HTH


Gary Parker
MIS Data Analyst
Manchester, England
 
Gary, your 2nd argument in the round() function should be -3, not 3. Correct?

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
Yes you're right. dyslexic fingers again.



Gary Parker
MIS Data Analyst
Manchester, England
 
Hello,

Thank you all for your reply.
What role does the -3 have in this formula?

Q

 
-3 is number of decimal places.

3 is to the thousandths ex 91,234.567
2 is to the hundredths 91,234.57
1 is to the tenths 91,234.6
0 is to the whole number 91,235
-1 is to the tens 91,240
-2 to the hundreds 91,200
-3 is to the thousands 91,000

Get the idea?

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top