Skip to Content
author's profile photo Former Member
Former Member

Round() and Truncate(0) not rounding or truncating

Round({#CountOfAppointments}, 1) & ' appointments for ' & Round({#TotalPatients}) & ' patients. Averaging ' & Round({#CountOfAppointments}/{#TotalPatients}, 1) & ' appointments per patient.'

I'm using CR 10 with Visual Studio 2010. Above is the formula. All of the values are integer data types. When I print I get

26.00 appointments for 15.00 patients. Averaging 1.70 appointments per patient.

What am I doing wrong?

Greg

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 19, 2011 at 09:51 PM

    Because the formula returns a mix of strings and numbers I don't get the option to format decimal places when I try to format the field itself.

    Also, I just downloaded and installed SP1 for my installation and there is no change to the behavior of Round(). I am using Crystal Reports for Visual Studio 2010. I'm not sure how to check version information of CR from within Visual Studio.

    Greg

    Edited by: GregDDDD on Aug 19, 2011 11:51 PM

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Greg,

      That can be the problem and likely is.

      Try dropping the string fields into the report to see how many decimal places there are then use the ToNumber function to convert and again drop that in the report and compare.... keep doing this in steps until you find the cause where the rounding causing the problem...

      Don

  • Posted on Aug 19, 2011 at 07:44 PM

    Hi Greg,

    When you say CR 10 with CS 2010 is it the full version of CR 10 or 10.2 or 10.5 included with VS 2005/2008?

    Neither are supported in VS 2010. Download CR for VS 2010: http://www.sdn.sap.com/irj/boc/crystalreports-dotnet

    Bottom of the page.

    What happens when you test that formula in the Report designer first?

    Don

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 19, 2011 at 08:13 PM

    Thank you for the replay.

    That is what I have. CR is imbedded in VS2010 and I design the reports is VS2010. I would think the Round() and Truncate () functions would work the same, regardless of what version of CR I have.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 19, 2011 at 08:15 PM

    Also, in the report designer, when I click on 'Main Report View' I see the same thing as on the printed page. It does not roound as I would expect.

    Greg

    PS As a test I tried summing and rounding a non-group field and found the same thing.

    Round(Sum({AICUApptCounts.ApptCount}), 1) returns 88.00

    Edited by: GregDDDD on Aug 19, 2011 10:21 PM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.