Excel

Saturday, July 9, 2011

SSRS : Displaying Parameter values as a Label in the report

We can just show the Parameter value in the text box by writing simple expression as
=Parameters!ParamName.value
But If the Parameter is a Multi value parameter, we have to write Join expression to display multiple selected values. Ex:  
                    = Join(Parameters!ParamName.Value, “,”)
 This will give you comma separated list of parameter values
In this method, if the number selected values are more, the text box will grow up the report might not look nice. If we want to show “ALL”, or <Some message> when ‘Select All’ is selected in the report parameter, we can use the following expression(Assuming that the values for the parmaters are supplied from the data set “DataSet_ParamName”)
=IIF(Sum(Fields!ID.Value, “DataSet_ParamName”)=Parameters!ParamName.Count, ”Al””,Join(Parameters!ParamName.Value, “,”))
We can also change the same expression to display some message when the selected Parameters count is greater than some values.
=IIF(Parameters!ParamName.Count >=2, ”Selected More than 2”,Join(Parameters!ParamName.Value, “,”))
If the selected parameter count is greater than 2 then it will show the message as as “Selected More than 2”.

SSRS - Serial number for the group column

                We were developing a report which contain a group (grouped by Product) and the group contain a detail row in it. We wanted to show Serial Number for the Products, we trying to use RowNumber function in SSRS but it didn’t come up as expected.  Finally we found the solution from Web which was written by Bilal Hani- a Microsoft Community Contributor as how to “add serial number to grouping column in SSRS Tablix”.

1. Open the report properties (right click on blank area outside the layout and click properties) or (Menu-->Report-->Report Properties)
2. Click on the code pane on the left
3. In the code window enter below script
Dim Counter as integer=0
public function getGroupCounter() as Integer
 Counter=Counter+1
 return Counter
end function
4. Go to the properties of the group (based on which group you need the group serial number)
5. Click the variables tab on the left
6. Click on Add and set Name as GroupCountValue and set the expression (in the expression window) as =Code.getGroupCounter, click ok and close the window.
7. Now in the textbox where you want to display the group number, set the expression as =Variables!GroupCountValue.Value
                Now the report will return the Serial Number for each Product as Expected. !!