Show decimal places in Crystal Reports

Posted on 2004-11-22
Last Modified: 2010-05-18
I'm using Crystal Reports 8.5
I have a number field that can have a varying # of decimal places.
For example the field could be:


The maximum a # could be is: 999.999999 it can never be 1000.

In reality the # of decimal places can vary to be any #...

I want to show 6 decimal places.
If there are not 6 decimal places I want to show only 4.
I could make the data in the database have only 6 or 4 decimal places if that could help in a solution.

I have a formula that I thought would do it, but unfortunately I can't format the maximum #, the formula becomes invalid for that 6th decimal point, it only works till 5 decimal points, and I'm not quite sure why...
Question by:DeeL9
    LVL 77

    Expert Comment

    Hello DeeL9,

    How is the field defined in the database?


    Author Comment

    It is stored as a NUMBER in an Oracle Database.
    LVL 100

    Expert Comment

    Have you used the Crystal format then set the number of places using a formula?

    What is wrong with your method?

    LVL 28

    Accepted Solution

    SO you want to determine the number of decimal places that exist in a number in that database field and then force either 4 or 6 places to be displayed?

    Add that database field to the report.
    Right click the field and choose Format Field.
    Click the number tab, then the Customize button.
    Click the X+2 button to the right of Decimals.
    In the editor, you can use a formula like this:

    if int({table.field}*10000) = {table.field}*10000 then

    Save and Close.

    Author Comment

    Describe what you mean?
    Format it to what and use what formula?

    Essentially if the # in the database is 123.4567 i want it to display 123.4567
    If the # is 123.456789, I want to show 123.456789.
    If the # is 1.2 I want it to show as 1.2.
    If the # is 1.234001 I want to show 1.234001... etc.

    toText doesn't work, because it rounds...
    LVL 28

    Expert Comment

    Here is one way ot od it:
    LVL 77

    Expert Comment

    Quote from original Q.
    "I want to show 6 decimal places.
    If there are not 6 decimal places I want to show only 4."

    Have the rules changed?


    Author Comment

    No they have not, I'm in the process of testing.
    Though, I think I will up the points because I may have another question.
    I think bdreed's way is working.

    I'll get back.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
    Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now