The SSRS Chr and ChrW functions are Text functions that return the character associated with the given ASCII code or value. This article explains how to use the Chr and ChrW functions to find the character code in an integer column with an example.
The syntax of the SSRS Chr and ChrW functions to find the character associated with the ASCII code number is as shown below.
Chr(97)
ChrW(125)
To demonstrate the SSRS Chr and ChrW functions, we use the Employee table, which has 15 records grouped by Occupation. The image shows the records in the Table report.
SSRS Chr function Example
As we don’t have any specific column to use for this example, we will extract the first two digits from the Income and Sales columns. Next, they will be used for the Chr function demonstration.
Let me add a new column to the right side of the Income column and name the header Chr Inc. Next, right-click the textbox under Chr Inc and choose 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 find the ASCII value’s character. The left function below returns the first two digits from the YearlyIncome column. The SSRS Chr function returns the character belonging to that ASCII code.
=Chr(Left(Fields!YearlyIncome.Value, 2))
Let me create one more new column to the right of the Sales column and name it Chr Sl. Next, right-click the textbox under it to write the below expression. Here, the SSRS Chr function returns the character representing the ASCII code (first two digits) from the Sales column.
=Chr(Left(Fields!Sales.Value, 2))
Please click the preview tab to see the characters associated with the ASCII value (first two digits) from the Income column. 50 = 2, 80 = P, 70 = F, and 85 = U. For more functions >> Click Here!
If you check the Sales Values result, 59 = ;, 49 = 1, 35 = #, and 69 = E.