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

How to round off a number and display as text?

Status
Not open for further replies.

cheerfulskeptic

Programmer
Feb 3, 2003
88
IN
Hello,
I have the following formula:

if {#rTotal} >0 then ToText (Truncate ({#rTotalComplete}%{#rTotal}, 1)) else "N/A"

the object is to print out a percentage (to 1 decimal place) or else print "N/A".
I tried Round and Truncate, but it doesnt work.
Any ideas?
Thanks
 
Why must you convert to text? How about this formula:

if {#rTotal}<>0 then Round({#rTotalComplete}%{#rTotal}, 1)) else 0

Then just format this as a percentage.



Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
dgilsdorf@trianglepartners.com
 
The requiremetns for the report state that there should be an &quot;N/A&quot; printed if the first variable (rTotal) is zero.
 
Maybe you can try to use If {#rTotal} >0 then ToText(Truncate{#rTotalComplete}%{#rTotal}, 1), 0) else &quot;N/A&quot;. Hope it can help.

 
I would do it a bit different

if {#rTotal} <> 0 then //it could be negative and still valid

ToText(round({#rTotalComplete}/{#rTotal}*100, 1),1)
else
&quot;N/A&quot;;

The only thing you have not explained is the format of this items

{#rTotal} and {#rTotalComplete}

Neither of these are in standard Crystal format for a formula or a field...so what are they???

if not a formula or field then there is probably your problem....



Jim Broadbent
 
Jim: Those are running totals.

Are you stating that the following does not work?

if {#rTotal} <> 0 then totext(Round({#rTotalComplete}%{#rTotal}, 1),1) else &quot;N/A&quot;

-k
 
SV- Sorry I rarely use RT's so missed it

No I didn't say it wouldn't work...just that I would do it differently

Jim Broadbent
 
In :

if {#rTotal} <> 0 then totext(Round({#rTotalComplete}%{#rTotal}, 1),1) else &quot;N/A&quot;

Wouldn't :

if {#rTotal} <> 0 then totext({#rTotalComplete}%{#rTotal}, 1) else &quot;N/A&quot;

Do the same thing? i.e. removing the round() function?

Reebo
Scotland (Sunny with a Smile)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top