Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Rounding Up Post Reply Post New Topic
Author Message
RaZeaL
Newbie
Newbie
Avatar

Joined: 16 Nov 2010
Location: South Africa
Online Status: Offline
Posts: 1
Quote RaZeaL Replybullet Topic: Rounding Up
     Posted: 16 Nov 2010 at 10:28pm
Hey. New to Crystal and scratching my head.
 
We have software that uses Crystal to generate Reports for us. Some of my clients need info changed on these reports. Easy enough, so I thought...
 
We are in the woodwork industry. My one client sells board in sheets. They do cut and edge. Now my problem is, I can't get the report to round up the boards from, lets say, 2.35 to 3 sheets. I have tried using the format field but it did not work.
 
The formula that was created is as follows:
 
numbervar total;
total := {@SumtotalsNumber} + ({@SumTotalsNumber} * ({tbl_Material.Waste} / 100));
if {@RoundTotals} then
    if total - truncate(total) <> 0 then
        total := truncate(total) + 1
    else
    total := total;
total
I understand that truncate takes the value down instead of up. How can I change this?
 
Thanks in advance.
 
Willem
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 17 Nov 2010 at 6:24am
Actually, looking at your formula, it should give you what you're looking for.
 
Let's use some actual numbers to walk through it.... assuming that total = 2.35 from your example:
 
Trunc(2.35) = 2 so 2.35 - Trunc(2.35) = 0.35 which is > 0.  Thus your result should be Trunc(2.35) + 1, which is 3.  From your example, this is the result you're looking for.
 
What result are you getting from this formula?
 
-Dell


Edited by hilfy - 17 Nov 2010 at 6:25am
IP IP Logged
bainsteven
Newbie
Newbie
Avatar

Joined: 15 Mar 2012
Location: United Kingdom
Online Status: Offline
Posts: 5
Quote bainsteven Replybullet Posted: 23 Apr 2012 at 4:56am
...or you could just use the "RoundUp" function...
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum