SSRS Mid Function

The SSRS Mid function is a Text function that returns the substring containing the user-specified number of characters from the given field starting from a given position. This article explains how to use the Mid function with an example.

The syntax of the SSRS Mid function to get the substring (middle) containing the required characters from the specified position is shown below. Here, 5 is the starting index position (1 is the first character), and 10 is the total number of characters. This means the below code returns the temp characters from the FullName starting from the fifth index position.

=Mid(Fields!FullName.Value, 5, 10)

To demonstrate the SSRS Mid function, we use the Employee table below, which has 15 records. The image shows the records in the Table report.

Source Table

SSRS Mid function Example

For this, let me add a new column to the right side of the Name column. Next, right-click the textbox under the Mid 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.

Chose the expression option

It opens the following expression window to return the substring. The SSRS Mid function below returns eight characters starting from the 2nd index position in the Name column.

=Mid(Fields!Name.Value, 2, 8)
SSRS Mid Function expression to extract substring from string

Please click the preview tab to see the substring from the Name field.

SSRS Mid Function preview to extract middle name

Similarly, let me create one more column to the right of the email column. Next, right-click the textbox under Domain Name to write the expression below. Here, the InStr function returns the index position of the @ symbol, and Len finds the total characters. Next, the SSRS Mid function returns the substring containing the domain name from the Email address column. For more functions >> Click Here!

=Mid(Fields!Email_Adress.Value,
Instr(Fields!Email_Adress.Value, "@") + 1,
Len(Fields!Email_Adress.Value) - Instr(Fields!Email_Adress.Value, "@"))
Mid expression. to get the domain name

Please check the report preview.

SSRS Mid Function to extract Domain Name from Email Address string