开发者

Formula for number is decimal or not in Crystal Reports

开发者 https://www.devze.com 2022-12-14 20:34 出处:网络
In my table I have values as: 5 6 12.06 15.933 I need 开发者_开发知识库to display in Crystal Reports as

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


You can also:

  1. add the field to your report normally
  2. right click it, select "Format Field"
  3. Click the Number tab and click Customize
  4. In the 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.


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!


  • Choose "format field" on the field you want to edit
  • In "Decimals" field out a Formula
  • Type this formula

     if(Int({Field})<>{Field}) 
      then 1 
      else 0 
    
0

精彩评论

暂无评论...
验证码 换一张
取 消