Data and Analytics with Mike250

SSRS – Capitalize the first letter

Need the ability to Capitalize the first letter of a string within SSRS? I found a gem of an SSRS function by Paul Turley of SolidQ.

From SSRS Report Properties switch to the Code tab and enter the following custom function:

Function ProperCase(InputString as String) As String
Dim i as Integer
If InputString  <> “” Then
Mid(InputString , 1, 1) = UCase(Mid(InputString , 1, 1))
For i = 1 To Len(InputString) – 1
If Mid(InputString, i, 2) = Chr(13) + Chr(10) Then
Mid(InputString, i + 2, 1) = UCase(Mid(InputString, i + 2, 1))
End If
If Mid(InputString, i, 1) = ” ” Then
Mid(InputString, i + 1, 1) = UCase(Mid(InputString, i + 1, 1))
End If
Next
Return InputString
End If
End Function

Now within your Reporting Services field expression, add:

=Code.ProperCase(LCase(Fields!field_name.Value))

Works a treat in SSRS 2008. Good luck!

1 comment

Leave a reply