Search code examples
stringcrystal-reportsconcatenationformulainventory-management

Crystal Reports: Formula unable to display as whole numbers


I am using the following formula:

If {USAGE.CURFY} = 0 
then "" 
else {USAGE.CURFY} & " (" & ({USAGE.CURFY_DAYSREMAINING} * 
{USAGE.USEDPERDAY})+{USAGE.CURFY} & ")"

I am having difficulty displaying the formula with the numbers as whole numbers. I keep getting decimals with two places. I can make it appear as round numbers using File, Options, Fields, Number... but when I upload it to our Crystal Server, the two decimal places show again.

So, I am under the impression that I need to round within the formula.

USEDPERDAY and CURFY_DAYSREMAINING are fields with decimal values. CURFY is a whole number.


Solution

  • You need to convert the numbers to strings:

    if {USAGE.CURFY} = 0 then "" 
    else totext({USAGE.CURFY},0) 
     & " (" & totext({USAGE.CURFY_DAYSREMAINING} * {USAGE.USEDPERDAY} + {USAGE.CURFY},0) & ")"
    

    The second parameter to totext() specifies the number of decimals.