I need the ability to toggle currency formatting for a decimal field on a Crystal Report. In cases where the decimal represents a percent, I do not want the currency symbol in front of the decimal. I currently do not have the ability to change the DataSet behind the report or how it is filled. So, I'd like to find a solution for this one the Crystal side.

My experience with Crystal Engine is limited so, I'd like to know if this is possible via a report function. The DataSet behind the report has a Boolean value (IsRatePercent) that can be used in a formula to determine whether or not the currency symbol should be displayed.

有帮助吗?

解决方案

The easiest solution is to use the conditional-formatting function associated with the field's display string property:

If {table.IsRatePercent} Then
   ToText(CurrentFieldValue,"###,###.## %")
Else
   ToText(CurrentFieldValue,"$###,###.##")

Another option:

If {table.IsRatePercent} Then
   ToText(CurrentFieldValue, 2, ",", ".") + " %"
Else
   "$" + ToText(CurrentFieldValue, 2, ",", ".")
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top