How to use SUM along with LOOKUP function
<p>In my SSRS report I have two tables: Losses(Table2) and Earned Premiums(Table 1), both coming from different datasets. I need to calculate ratios based on those Losses and Earned Premiums for each month and year. For that I used LOOKUP function and it works fine:</p>

<pre><code>SUM(Fields!PaidLosses.Value) / Lookup(Fields!AccidentYearNum.Value &amp; Fields!AccidentMonthNum.Value, Fields!YearStartRisk.Value &amp; Fields!MonthStartRisk.Value, Fields!EarnedPremium.Value, "EarnedAllCoverages")
</code></pre>

<p><a href="https://i.stack.imgur.com/LeVte.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LeVte.png" alt="enter image description here"></a></p>

<p>But now I need to calculate <code>TOTALS</code>. Which is Total Losses for each month and year divided by Total Earned Premium for each month and year. 
Based on this article  </p>

<p><a href="https://i.stack.imgur.com/kLpDJ.png" rel="nofollow noreferrer">http://www.sqlservercentral.com/blogs/salvoz-sql/2013/05/27/sum-result-of-ssrs-lookupset-function/</a></p>

<p>I inserteded this Custome Code: </p>

<pre><code>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
</code></pre>

<p>And now I am using this expression:</p>

<pre><code>=SUM(Fields!PaidLosses.Value) / Code.SumLookup(LookupSet(Fields!AccidentYearNum.Value &amp; Fields!AccidentMonthNum.Value, Fields!YearStartRisk.Value &amp; Fields!MonthStartRisk.Value, Fields!EarnedPremium.Value, "EarnedAllCoverages"))
</code></pre>

<p>But that doesnt give me correct answer for some reason. 
<a href="https://i.stack.imgur.com/YLeaa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YLeaa.png" alt="enter image description here"></a>
What am I missing here?</p>