Search code examples
stringrdlc

Removing comma from the string in rdlc


How to remove comma from the end of a string in RDLC text box formula field?

Here is the expression:

=Fields!Titles.Value

Solution

  • If you're sure there won't be any other commas (and are okay with removing all of them), you can replace the commas with nothing, like this:

    =Replace(Fields!Titles.Value, ",", "")
    

    If there could be commas elsewhere in the fields that you don't want to remove (and you want to remove commas occurring at the end of the field only), you could do something like this:

    =iif(Right(Fields!Titles.Value, 1) = ",", 
         Left(Fields!Titles.Value, Len(Fields!Titles.Value)-1),
         Fields!Titles.Value)
    

    If there can be whitespace before or after the comma, you'll need to add handling for that also (use Trim, LTrim, and RTrim as needed for your situation).