Search code examples
reporting-servicesssrs-2008

How to use concatenate command in SSRS "Code.SumLookup(LookupSet)" function?


The custom code nested in report properties :

Function SumLookup(ByVal items As Object()) As Decimal  
If items Is Nothing Then  
Return Nothing  
End If  
Dim suma As Decimal = New Decimal()  
Dim ct as Integer = New Integer()  
suma = 0  
ct = 0  
For Each item As Object In items  
suma += Convert.ToDecimal(item)  
ct += 1  
Next  
If (ct = 0) Then return 0 else return suma   
End Function 

My command like this :

=Code.SumLookup(LookupSet("9040101", Fields!norek.Value,Fields!tgl10.Value, "NR_01"))

if I run that command the result is not error. the value will be 100

than

I just want to make Fields!tgl10.Value dynamically change when the parameters also change. so I changed it

from :Fields!tgl10.Value to : "Fields!tgl" & parameters!nm_kolom.Value & ".Value"

become this

=Code.SumLookup(LookupSet("1040101", Fields!norek.Value, "Fields!tgl" & parameters!nm_kolom.Value & ".Value", "NR_01"))

but I found an #error instead

Is there any missing from the my new command?

Thank You Regardz


Solution

  • The result of your concatenated expression will by a string, but not a field reference. Try this instead:

    Fields("tgl" & Parameters!nm_kolom.Value).Value