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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Roundup formula

Status
Not open for further replies.

GCL2007

IS-IT--Management
Dec 11, 2007
167
US
Using Crystal 11.5, Am looking to find a better solution to this rounding problem. Have a value on the report that I typically always want to round up. It is the value of number of containers based on a calculation. We always want it to round up (for example if the calculation comes to 13.4, we'd want a value of 14 returned).
The calculation is Roundup(1/{CONTAINER.PTSPER})
That was working fine, but came across a value of 1/.083333 which comes to 12.00004 which the report rounds up to 13. In this case it's just a rounding issue and we'd want to keep it at 12. Anyone know of a way of reporting this so it makes more sense? If it falls within a certain amount don't ROUNDUP, otherwise Round up.
 
I think something like below will do what you want.
you will need to replace the .0001 with whatever decimal value you desire to enact the desired rounding.

(If remainder is greater than value then roundup else floor.)

//{@RoundIF}
IF remainder(1/{Container.PTSPer}) > .0001 then roundup(1/{Container.PTSPer}) else floor(1/{Container.PTSPer})
 
Just use ROUNDUP with the option argument. For example
ROUNDUP({table.field},4)
will round up to four places.
So your example should round up to 12 since you are only looking at four places to the right of the decimal.

Howard Hammerman,
Crystal Training and Crystal Material
On-site classes and one-on-one coaching
Low-cost telephone/email support
 
This may not be the most efficient way, but it does work:

Code:
RoundUp(Val(ToText((1/{CONTAINER.PTSPER}), '0.000')))

To control the degree of 'tolerance', simply vary the number of zeros in the ToText component.

Cheers
Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top