robjlong
9/28/2015 - 8:35 PM

SSRS LookupSet Sum

SSRS LookupSet Sum

-- Returns the ratio of Blue Units to Red Units using the LookupDataSetName

= Code.SumLookup(LookupSet(Fields!Sales_Person.Value, Fields!Sales_Person.Value, Fields!Blue_Units.Value, "LookupDataSetName")) / 
Code.SumLookup(LookupSet(Fields!Sales_Person.Value, Fields!Sales_Person.Value, Fields!Red_Units.Value, "LookupDataSetName"))
// Code that can be used to SUM the values in a LookupSet
// This code must go in the Report Code Section

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