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 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 SSRS charts and SSRS table report from our SSRS tutorial page.

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. Also, check out the SSRS grouping

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

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 SSRS INSTR function returns the index position of the @ symbol, and SSRS LEN finds the total characters. Next, the SSRS Mid function returns the substring containing the domain name from the Email address column.

=Mid(Fields!Email_Adress.Value,
Instr(Fields!Email_Adress.Value, "@") + 1,
Len(Fields!Email_Adress.Value) - Instr(Fields!Email_Adress.Value, "@"))

Please click the preview tab to see the substring from the Name field and the extracted domain names from the Email address. Please refer to the SSRS RIGHT and also, check the SSRS LEFT function from the list of available SSRS functions.

SSRS Mid Function to extract Domain Name from Email Address string