The SSRS Trim function is a Text function that removes the leading and trailing spaces from the given field and returns a copy of the string. This article explains how to use the Trim function to remove empty space from the left and right sides of a string with an example.
The syntax of the SSRS Trim function to create a new string by removing the leading and trailing spaces is as shown below.
=Trim(Fields!Name.Value)
We use the Employee table below, which has 15 records to demonstrate the SSRS Trim function. The image shows the records in the Table report. If you notice, there are empty spaces on the right and left side of the content in the Full Name and Email columns.
SSRS Trim function Example
For this, let me add a new column to the right side of the Full Name column. Next, right-click the textbox under the Trimmed Name and choose the Expression. To understand the report, I suggest you refer to the articles on charts, tables, grouping, and format tables in SSRS.
It opens the following expression window to remove lead and trail spaces. The SSRS Trim function below deletes the empty spaces from the left and right sides of the Full Name column and returns a new string.
=Trim(Fields!FullName.Value)
Please click the preview tab to see the result. It has removed the empty spaces on the right and left sides of Full Name. To remove the left side, use LTrim, and right-only use the RTrim function.
Similarly, let me create one more column to the right of the email column. Next, right-click the textbox under Mail to write the below expression. The SSRS Trim function removes the leading and trailing spaces from the Email column.
=Trim(Fields!Email.Value)
To achieve this, you can also try the expression below. For more functions >> Click Here!
=LTrim(RTrim(Fields!FullName.Value))
Please check the report preview.