Search code examples
reporting-servicesssrs-2008ssrs-2008-r2ssrs-2012ssrs-tablix

SSRS Custom Code Loop


Can any one of you please explain me how the loop (For, While) loops works in here

A      B
Apple  13
Grape  5
Orange 16  

I have written this code, but it's not working here.

Public Function SafeConvert(ByVal num As String) As String

Dim S as Integer
For i as Integer = 0 to 2
  s += num
next
Return s

End Function

Instead of adding each number, SSRS is adding only the last cell 16 * 3 times and showing incorrect result.

And can you please answer this question as well.

I have a matrix whose text box contains 3 values, how do I calculate the sum of all the values for Q27_A_1 if the value is less than 5?

1


Solution

  • Yeah, I understand your point of Sum function to perform this operation. it would be very easy to achieve this by using Sum function. But i have a giant report with more than 5000 matrix boxes and i need to apply on it. So just wants to confirm if the custom codes works in here and whats wrong in this code of lines.

    Public Function SafeConvert(ByVal num As String) As String

    Dim S as Integer

    For i as Integer = 0 to 2

    s += num

    next

    Return s

    End Function

    What it is doing is just adding the last cell for 3 times. i want to add all the value of cell during runtime.