Reputation: 31
In my table I have values as:
5
6
12.06
15.933
I need to display in Crystal Reports as
5
6
12.1
15.9
Can anyone get me formula to do above?
I tried this formula:
tonumber({table.field})
But I get the result as below which I don't want.
5.0
6.0
12.06
15.93
Upvotes: 3
Views: 35241
Reputation: 12721
Type this formula
if(Int({Field})<>{Field})
then 1
else 0
Upvotes: 1
Reputation: 448
You can also:
Number
tab and click Customize
Decimals
formula, enter something like:
if {@test} - truncate({@test}) <> 0 then
1
else
0
The formula tests if the field is an int. If so, show 1 decimal place, otherwise show 0. This method has the advantage of not changing the datatype to text which will make totalling and calculating easier.
Upvotes: 7
Reputation: 22424
Create a formula with:
if remainder({database.field},truncate({database.field})) = 0 then
totext({database.field},0)
else
totext({database.field},1);
This will however convert the number to text so if you have to do any calculations then just use the original {database.field} in your calculations. This will also round to one decimal place. Not the most elegant!
Upvotes: 1