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!

Need to "round up" in Crystal 8.5 1

Status
Not open for further replies.

joybee36

Technical User
Feb 10, 2006
29
US
A full carton of books shipped = 5 books. We are trying to bill our customer for full and partial boxes of books shipped, and I need for Crystal to ALWAYS round up to the next number unless the quantity of books sold is >5. How can I get this formula to NOT return a quantity of 8.4 for an order of 42 books, but "9" for 8 full boxes and 1 partial?

Here's what I have so far:

if Sum ({oelinhst_sql.qty_ordered}, {oehdrhst_sql.ord_no})>5 then (Sum ({oelinhst_sql.qty_ordered}, {oehdrhst_sql.ord_no})/5) else 1

 
I think you meant you want to round up unless the quantity is less than 5. Try this:


if Sum ({oelinhst_sql.qty_ordered}, {oehdrhst_sql.ord_no})>5 then
-int(-(Sum ({oelinhst_sql.qty_ordered}, {oehdrhst_sql.ord_no})/5)) else
1

If 1 is your default however, I think you would get the correct result by just using:

-int(-(Sum ({oelinhst_sql.qty_ordered}, {oehdrhst_sql.ord_no})/5))

...since anything under five would round up to 1 anyway.

-LB
 
Perfect! I always get such great info on this board...
 
Another method for rounding up:

If {fieldname} - truncate({fieldname}) <> 0 then
truncate({fieldname}) + 1
else
{fieldname}

-------------------------------------------------------------------------------------------------------------------------
"Now I can look at you in peace; I don't eat you any more." Franz Kafka, while admiring fish in an aquarium
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top