Crystal Reports 2013: Adding Leading Zeros to Sum in Group Footer

495 Views Asked by At

I have a report in Crystal Reports 2013 that is grouping multiple transactions into an aggregate transaction by account number. The value is Amount, so in the Group Footer is it listed as SumofAmount. The field must be 17 characters long, so any number must be padded with leading zeros.

The values are assumed to be decimal, so they are all integers. For example, the following transformations would occur:

3123 needs to be:        00000000000003123
23283792387 needs to be: 00000023283792387

If I right-click in Formula Workshop > Formatting Formulas > Group Footer #1 > SumofAmount I get a New Formatting Formulas which has leading zeros as an option, but how do I define this with a Boolean (this is a requirement)?

1

There are 1 best solutions below

0
On
  • Right click on the field you need to have leading zeros.
  • select format field
  • select the common tab
  • select X2 to the right of Display String
  • Enter the following formula

right("000000000000000"&totext(CurrentFieldValue,"#"),15)

This assumes the total length of the field is 15. To change for your required length

  • change the number 15 to the desired length of the field
  • change the number of 0's between the quotes to at least the desired length of the field

Repeat this for any field you need leading zeros