SAP Knowledge Base Article - Public

1291478 - How to format a string to a percentage with 2 decimal places?

Symptom

  • A formula needs to be formatted as a percentage with 2 decimal places e.g. (93.33 %).
  • Is it possible to format the string to do that?

Reproducing the Issue

  • Product - Crystal Reports XI Release 1, Crystal Reports XI Release 2
  • OS - Windows XP Professional 
  • Database - Any 

Resolution

1) Convert the string to a number using ToNumber and then apply a format against it.

2) First check if it is a numeric text.

3) If(NumericText({@my_field})) then ToNumber({@my_field}) else 0

4) Now apply the numeric formats to this number.

5) Finally, there is also a ToText( ) function which will convert the number back to a string with formatting options applied.
 

Keywords

Format, String, Percentage, Decimal. , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To

Product

SAP Crystal Reports XI ; SAP Crystal Reports XI R2