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

How to hide the decimal part, based on the condition ? 4

Status
Not open for further replies.

CrystalReports9

Programmer
Jan 10, 2003
124
US
Existing Data
-------------

C1 C2
-- -----
A 10.000
B 20.000
C 30.000
D 40.000
E 50.000
F 60.000


Result to be
------------

C1 C2
-- -----
A 10.000
B 20.000
C 30 <----------- Remove the Decimal
D 40.000
E 50.000
F 60 <----------- Remove the Decimal

Question :
----------
How the Decimal places can be eliminated based on the column c1 value ?
 
Create a formula like this:
Code:
if {table.C1} in ["C","F"] then
    ToText({table.C2},0)
else
    ToText({table.C2,3)
Place this on your report as the C2 column ans remove the {table.C2} field from the report canvas.

~Brian
 
Hi Brian

Really u have a BRAIN....

Excellent it works out very well.... Thank u soo much..

Anto
 
You could just conditionally format the field itself. That way, you won't need to remove the field, and you'll be working with a Numeric field instead of a String field. Now you'll be able to summarize properly.

In the Format editor for the field, go to the Number tab. Click the "Customize" button. Click the X2 button beside decimals and use a formula similar to the following:
SELECT {Table.C1}[1]
Case "C","F" : 0
Default : 3

HTH




Bob Suruncle
 
Thanks for sharing that Bob*. Definitely easier to do that than to convert it to text in formula.

~Brian
 
I have a number field that I need to convert ToText in a formula. I am trying to break out the Dollars from Cents.
We want the formula to appear as follows on the report:

*******************************999 DOLLARS and 99 CENTS

So, I have a numeric field with a value of 999.99 in it.
I am doing a Replicate String of '*' for a particular number - length of the numeric field.
I am then converting the numeric field to text with a 0 to indicate the number of decimal places to carry this value. The problem is that it is rounding my 999 to 1000.
Is there any way to NOT have it round to 1000 and just print the 999?

Thank you
 
Try:

totext(truncate({table.amount},0),0)

LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top