cancel
Showing results for 
Search instead for 
Did you mean: 

Display String formula to remove commas and decimals

Former Member
0 Kudos

I am using Crystal Reports for .Net (Visual Studio 2010).

In the Display String formula, I need to strip all commas and decimals. I have tried to use:

If Not IsNull({table.field}) Then

ToText({table.field}, 0, "")

but the ToText function gives error "Too many arguments passed".

Many posts on the internet suggest trying to use a combination of Replace with the CStr function like the following:

If Not IsNull({table.field}, 0, "") Then

replace(cstr({table.field},0),',','')

but the cstr function is returning error "Too many arguments passed".

Anyone have a working function that will remove commas and decimals from a string?

Thanks...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos


We found a solution.

Display String function is:

Replace(Replace(CStr({table.field}), ',', ''), '.00', '')

Suppress function is:

CStr({dsMasterProblems.snomed}) = '0' Or CStr({dsMasterProblems.snomed}) = '0.00'

Thanks....

JWiseman
Active Contributor
0 Kudos

hi Marty,

that's good news.

before you get too far into designing your report, if exporting is a requirement for your end users with the above Display String formatting then you should know that exporting and Display String do not always get along...e.g. if you're exporting to excel then the formatting will revert to before the display string. in cases where you do need the export with the chosen format, then format within the formula like you were trying to do before.

cheers,

jamie

Answers (1)

Answers (1)

JWiseman
Active Contributor
0 Kudos

hi Marty,

you can use something like this...

If Not IsNull({table.field})

and isnumeric({table.field})

Then  ToText(tonumber({table.field}), 0, "")

cheers,

jamie