Assuming your (G-$ZZ9.99) field is P1F1, the following simple formula will work:
round[P1F1;1]
The syntax for the round function is round[number;control]
where number is the value you want to round, and control is the value you want
to round to. Since you want to round to the nearest whole number, you use 1 as
the control value. If you wanted to round to the nearest $0.50 you would use
0.5 as your control value.
Note that DP's round function does rounding the way you were probably taught in
school, also known as "Round Half Up". When rounding to a whole number, values
below 0.5 always round down and values >= 0.5 always round up. For example,
2.50 always rounds up to 3 and -2.50 always rounds up to -2.
This is different from the "Round Half Even" or "Banker's Rounding" that many
software programs now use. In banker's rounding, if the decimal portion is
exactly 0.5, the number rounds up or down to the nearest even integer. This
helps to offset the creep of rounding errors that get introduced by always
rounding up. So 2.50 rounds down to 2 but 3.50 rounds up to 4. And -2.50 rounds
up to -2 but -3.50 rounds down to -4.
If you need a formula for banker's rounding rather than DP's built-in "Round
Half Up" method, that will take a bit more work. Here's a formula I slapped
together that seems to work in the tests I've thrown at it:
--------------------------------------------------------------------------------
/* Formula to do Banker's Rounding (aka Round Half Even) */
/* Insert value, field, or RV to be rounded before the 'cases' operator */
P1F1 cases
case abs[cv-round[cv;1]]=0.5 of
if
convert["G-9999999999";subfield[apply.format["G-99999999999.9";cv];'.';1]] // 2
= 0 then
convert["G-9999999999";subfield[apply.format["G-99999999999.9";cv];'.';1]]
else
if cv > 0 then round[cv+0.1;1] else round[cv-0.1;1] endif
endif
endof
default round[cv;1]
endcases
--------------------------------------------------------------------------------
(I tried to keep the lines from wrapping but it may not work in all clients.)
Tim Rude
----- Original Message -----
From: Brian Finn
To: [email protected]
Sent: Wednesday, September 14, 2011 6:01 PM
Subject: [Dataperf] Round up the Whole Dollar
I need assistance creating a formula that will roundup a (G-$ZZ9.99) Field a
whole dollar, any suggestions?
Thank You
--
Brian Finn
Client Services / Database Administrator
Local: 602-712-1515 Fax: 602-246-1782
Toll Free: 1-866-332-8453
Arizona Contractor License Center
------------------------------------------------------------------------------
_______________________________________________
Dataperf mailing list
[email protected]
http://lists.dataperfect.nl/mailman/listinfo/dataperf
<<23_5eef08f759bb5d47e094b9fb828ef8ed.jpg>>
<<facebook.png>>
<<twitter.png>>
<<reach_cast.png>>
<<rss_icon.png>>
_______________________________________________ Dataperf mailing list [email protected] http://lists.dataperfect.nl/mailman/listinfo/dataperf
