开发者

Formatting data in Crystal Reports

I have a field which is a Double. For display on a the report, if that value is negative, then I need to reverse the number by multiplying it by -1. The result should be formatted like this: "(1,000)" (notice no "-" sign). How can I do this in Crystal? I was using a Display String formula to try to d开发者_开发问答o this since the "Reverse sign for display" option doesn't work for me (because it needs to be a formula for other reasons).

So far I have:

if {columnName} < 0 then
  "(" & ToText({columnName}, "#,###", 0) & ")"
else
  "(" & ToText({columnName} * -1, "#,###", 0) & ")"

But this gives me something like this: "(-6,500)", and I need to get rid of that pesky minus sign.

Edit:

I implemented a formula field like this:

-Abs({columnName})

Then selected the format that looks like (1,234) from the format list as Craig answered below.


Crystal Reports supports 'accounting' formatting w/o much effort:

  • right click field, select Format Field...
  • select Number tab (if not selected)
  • choose the style that resembles '(1,123.00)'

** edit **

You can also apply this formatting to a formula field.


I have accomplished my requirement this way< I have added a formula and assigned sum of the required field then I set its Format (12,34.00) also i have removed Dollar sign.

Formula = replace(totext(Sum({myfield}) * -1),"$","")


I have face same pro blame but it OS specific . ON windows xp no any formatting problem but above xp this issue face. Use following formula in Display Formula after removing all formatting .

Replace(Replace(Replace(ToText (CurrentFieldValue, "##,##,##,##0.00", 2),"$",""),"-",""),",","")

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜