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

Rounding numbers and dollars 1

Status
Not open for further replies.

lgmin

Programmer
May 20, 2005
71
US
I am using Crystal Reports 10.0.

I have many reports with numbers in them, some formatted as dollars, others rounded to one decimal. Is there a way to guarantee that my subtotals and totals add up to the rounded number.

For example: 1.9 and 4.1 and 2.3 and 1.6 and 5.3 subtotals to 15.1 on my report because of the rounding, but if you add these actuals numbers it is 15.2. We want the report to show the 15.2, what the rounded numbers add up to and not what the total of the numbers add up to and then rounded.

Thanks.

lgmin
 
Sure, use the actual fields not rounded as the summary, or in the summary only use a formula which is rounding.

-k
 
Can you give me a little more information. How do I specify whether I want to use the number as is, or as a rounded number?

What I want to do is add the rounded numbers, but in my summary I don't know how to say add the rounded numbers and not the actual numbers.

Thanks.

lgmin
 
An example of a rounded number in a formula is:

round({table.field},1)

Now you can use conventional summaries in Crystal against this field to use the rounded value.

-k
 
Ok, I have really missed the boat on this one. Are you saying that instead of pulling my fields into my Detail section and formatting the decimal place to one and adding summaries, I should create a formula using the round function on every field I pull into my detail section, and then from there I can use the summary function and it will add up right?

Is there a way to turn off the round function? Seems like that would be alot easier.

Thanks.

lgmin
 
Since a formula takes about 30 seconds to develop, posting seems to be much more labor/time intensive.

Create the formula and us it as required. The other advantage is that you know the exact decimal precision that you wish it to perform the sum against.

-k
 
I think I have drowned on this one.

What do you mean by "posting seems to be much more labor/time intensive"?

I have inherited the maintenance of many accounting reports where they dragged the fields into the detail section, did a summary on it, and created the report. Because they are showing only once decimal, it seems to be automatically rounding from the 5 decimals the number actually has, so the summary is not adding up correctly if you were to add the numbers actually displayed. If I have to go back and create a formula for every field ever used in a report I will be spending all my time fixing these reports. It seems to me there should be a way to just format the field, or the summary, to fix the problem.

From what I understand you are saying, I should create a formula for every number field I ever use in a crystal report so that the summary will add up correctly?

Like I said, this just is not clicking, and it seems there should be an easier way.

Thanks for all your help and patience with me!

lgmin
 
lgmin,

You will, indeed, need to write a formula for every field that needs to be rounded for totals. Reducing the decimals using formatting is what I call "fake" rounding. It looks rounded but does not affect the underlying value. Totals will always use the underlying (unrounded) value. Sorry.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides for Formulas, Parameters, Subreports, VB, .NET, Tips and Tricks
 
What they're saying is that you need to round the actual numbers, so that those are the numbers added up. Crystal will let you display 1.513 as 1.5, or even as 2, depending on the display options. But it would be added as 1.513, with the problem you mentioned. Whereas the 'Round' command changes the actual value, which then would add in line with what is shown.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Ok. Now I get it. Alot of work for me to clean these up though.

Is there a way to keep the titles of the columns when I am replacing the field with the formula. Currently, if I delete the field, the title is going with it.

Thanks.

lgmin
 
If you name your formula the same thing as the column label, it will automatically be created when you add the formula to the detail section.

-LB
 
I don't get labels created when I drag a field over to my details section, so I always create them separately by inserting a text box into the header. That is why I don't understand why my text boxes in my header are deleting out when I delete the field in the details section. I don't want to have to re-create all these too. Is there a way to prevent these from deleting, and why are they deleting anyway? How are they getting linked together?

Thanks.

lgmin
 
Go to file->options->layout->field options and check "insert detail field titles". Then you will automatically get column labels.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top