<

Variable, Custom Code and Assembly reference in SSRS

Published on
14,317 Points
5,917 Views
4 Endorsements
Last Modified:
Approved
How to use Variables  and Custom code in SSRS report and Assembly reference to use compile shared code in SSRS.

Its big question for all who are working with SSRS. It is easy to create assembly and refer in SSRS report, still there are some steps need to be applied. Let's look in details.


1. Variable in SSRS


If you want to use or hold value through out the request then refer the SSRS variables. It is available in any part of report and lifetime of variable is request to server. It reset when new request comes to server.

You can create variable using Menu=>Report=>Report Properties=>Variables

Add variables to SSRS
You can use this variable in calculation of field or anywhere in the report as below:

Use of Variable in Field expression

2. Custom Code in SSRS


Custom Code is very useful where you can not achieve desire result using Sum/Avg/Count/Running Total.

For example in report you are displaying records (Products) those have price > $10 That time you can hide those rows in report but total not eliminate hidden rows in count. In these type of case it's good to have custom code. Let's see how can we create custom code.

You can create custom code at Menu=>Report=>Report Properties=>Code

Sample of Custom Code
Note: Make sure SSRS support custom code in VB only.

Let's time to see how to use the custom code in report fields.

Use of Custom Code function in Field expression

3. Assembly Reference in SSRS


This is the very crucial part of the Assembly reference in SSRS. It is very useful when you want to use logic in other reports rather than in single one (Shared custom code).

To do that Just create one Library (As you know it is basic task.) Build that and paste it to

Consider for SQL 2008

To load assembly in SSRS
%\Program Files%\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\bin

To load assembly in BIDS (Development environment)
%\Program Files%\Microsoft Visual Studio %Installed Version%\Common7\IDE\PrivateAssemblies

Now time to consume or add assembly reference to SSRS.

You can add assembly reference  at Menu=>Report=>Report Properties=>References

Add assembly reference
1. Click on Add Assembly reference and select your library.
2. Add class and create instance in second frame.

Use of assembly function in Field expression

That's it for now. Hope meet with new Topic again.

Thanks,

Alpesh Patel
4
Comment
0 Comments

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Join & Write a Comment

Wrapper-1-Query. Use an Excel function to calculate a column for an Access query. Part 1. Shows a query in Access that has a calculated column with the results of an Excel worksheet function. See how to call a wrapper function from a query, and …
A query can call a function, and a function can call Excel, even though we are in Access. This is Part 2, and steps you through the VBA that "wraps" Excel functionality so we can use its worksheet functions in Access. The declaration statement de…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month