1998005 - How to calculate number of decimal places in Crystal Reports Numeric value

SAP Knowledge Base Articles - public

# 1998005- How to calculate number of decimal places in Crystal Reports Numeric value

### Symptom

How to calculate number of decimal places in Number field?

### Environment

• Crystal Reports 2008
• SAP Crystal Reports 2011

### Resolution

To calculate the number of decimal places use the following formula logic:

(Let's take 1234,56700 as an example)

1. Separate Decimal part of the whole number using Floor function: abs({NumberField} - FLOOR({NumberField})) = 0.56700
2. Convert the number to a string: totext(abs({NumberField} - FLOOR({NumberField}))) = "0.56700"
3. Reverse the string: StrReverse(totext(abs({NumberField} - FLOOR({NumberField})))) = "00765.0"
4. Convert the string to a Number: Tonumber(strreverse(totext(abs({NumberField} - FLOOR({NumberField}))))) = 765.0
5. Convert the number to a string: Totext(Tonumber(strreverse(totext(abs({NumberField} - FLOOR({NumberField}))))),0,"") = "765"
6. Calculate the length of the string and the final formula will look like:

Length(Totext(Tonumber(strreverse(totext(abs({NumberField} - FLOOR({NumberField}))))),0,"")) = 3

### Keywords

Dynamically format number of decimal places, floating, , KBA , BI-RA-CR , Crystal Reports designer or BusinessViews Manager , How To

### Product

Crystal Reports 2008 V0 ; Crystal Reports 2008 V1 ; SAP Crystal Reports 2011 ; SAP Crystal Reports 2011, feature pack 03 ; SAP Crystal Reports 2013